On Fri, February 2, 2007 9:11 am, Dan Shirah wrote: > I am trying to populate a dropdown list to contain the current year to > 10 > years in the future. Below is the code I'm using: > > <?PHP > for ($y=0;$y<=10;$y++) { > $years=date <http://php.net/date>('Y')+$y; > $short_years=date <http://php.net/date>('y')+$y; > echo "$short_years"; > echo "<option value=\"$short_years\">$years</option>"; > } > ?> > I want the selection value to be 2007, 2008, 2009, 2010.... and the > $years > accomplishes this. Howeverm I want the option value to be the two > digit > year ex. 07, 08, 09, 10...the $short_years semi accomplishes > this....instead > of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to > output the > two year for 07, 08, 09 without it cutting off the zero? for ($year = date('Y'); $year <= date('Y') + 10; $year++){ $short_year = $year - 2000; echo "<option value=\"$short_year\">$year</option>\n"; } Using the 2-digit year as your value is almost for sure a really Bad Idea, unless you are dealing with legacy software that absolutely needs it... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php