PHP – date menus

Jun, 5 -- Categories: PHP

<?php

$today = getdate();

$day = $today['mday'];
$month = $today['mon'];
$year = $today['year'];
$mtharr = array(“January”,”February”,”March”,”April”,
“May”,”June”,”July”,”August”,”September”,
“October”,”November”,”December”);

?>

<select name=”start_day”>

<?php

for ($i=1;$i<=31;$i++) {

echo “nt<option value=”$i”";

if ($i == $day) echo ” selected”;
echo “>$i</option>”;

}

?>
</select>

<select name=”start_month”>
<?php

for ($i=1;$i<=12;$i++) {

echo “nt<option value=”$i”";
if ($i == $month) echo ” selected”;
echo “>” . $mtharr[$i-1] . “</option>”;

}

?>

</select>

<select name=”start_year”>
<?php

for ($i=0;$i<=9;$i++) {

$tmp = $today['year'] + $i;
echo “nt<option value=”$tmp”";
if ($today['year'] == $tmp) echo ” selected”;
echo “>” . $tmp . “</option>”;

}

?>

</select>