Re: Year

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



HI Dan

try this this should work 100%;

echo "<select>";
for ($y=0;$y<=10;$y++) {
$years=date('Y')+$y;
$short_years=date('y')+$y;
printf("<option value=\"%02d\">%d</option>",$short_years,$years);

}
echo "</select>";

On 2/2/07, Dan Shirah <mrsquash2@xxxxxxxxx> wrote:

Hello all,

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?

Reagrds,

Dan




--
Have A plesant Day
Chetan. D. Rane
Location: Pune , India
Contact: +91-9890792762
otherID: chetscool@xxxxxxxxx
            chetrane@xxxxxxxxxxxxxx

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux