Hi all,
i'm building a simple date input with php using drop down list box
the problem i faced is "leap year"
how do i display 29 day in the drop down list box while user selected a leap year
if user make an option on day first then only go to
Select the year what i'm suppose to do ?
here my code:
<tr><td width="20%" bgcolor="#DDE8EE"><span class="input_name">Effective Date :</span></td><td bgcolor="#DDE8EE">
<select name="Year" id="Year">
<option value="">Year</option>
<?php
$end = (date("Y")+3);
for($y=2010;$y<$end;$y++)
{
echo "<option value=".$y.">".$y."</option>";
}
?>
</select>
<select name="Month" id="Month">
<option value="">Month</option>
<?php
$mon = array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec");
for($m=1;$m<=12;$m++)
{
echo "<option value=".$m.">".$mon[$m]."</option>";
}
?>
</select>
<select name="Day" id="Day">
<option value="">Day</option>
<?php
$day = array("",31,28,31,30,31,30,31,31,30,31,30,31);
echo "<SCRIPT LANGUAGE="javascript"><!--n";
echo "return LeapYearChecking();n";
echo "// --></SCRIPT>n";
LeapYearChecking()
for($i=2010;$i<$end;$i++)
{
if($i%400==0||($i%100!=0 && $i%4==0))
{$day[2] = 29;}
else{$day[2] = 28;}
}
?>
</select></td></tr>
If you got better advice for the date input in another format like date time picker
please kindly share the link here i'll be thankful T^T!