<?Php
$todo=$_POST['todo'];
if(isset($todo) and $todo=="submit"){
$month=$_POST['month'];
$dt=$_POST['dt'];
$year=$_POST['year'];
$date_value="$month/$dt/$year";
echo "mm/dd/yyyy format :$date_value<br>";
$date_value="$year-$month-$dt";
echo "YYYY-mm-dd format :$date_value<br>";
}
?>
<form method=post name=f1 action=''><input type=hidden name=todo value=submit>
<table border="0" cellspacing="0" >
<tr><td align=left >
<select name=month value=''>Select Month</option> <option value='01'>January</option> <option value='02'>February</option> <option value='03'>March</option> <option value='04'>April</option> <option value='05'>May</option> <option value='06'>June</option> <option value='07'>July</option> <option value='08'>August</option> <option value='09'>September</option> <option value='10'>October</option> <option value='11'>November</option> <option value='12'>December</option> </select>
</td><td align=left >
Date<select name=dt >
<option value='01'>01</option> <option value='02'>02</option> <option value='03'>03</option> <option value='04'>04</option> <option value='05'>05</option> <option value='06'>06</option> <option value='07'>07</option> <option value='08'>08</option> <option value='09'>09</option> <option value='10'>10</option> <option value='11'>11</option> <option value='12'>12</option> <option value='13'>13</option> <option value='14'>14</option> <option value='15'>15</option> <option value='16'>16</option> <option value='17'>17</option> <option value='18'>18</option> <option value='19'>19</option> <option value='20'>20</option> <option value='21'>21</option> <option value='22'>22</option> <option value='23'>23</option> <option value='24'>24</option> <option value='25'>25</option> <option value='26'>26</option> <option value='27'>27</option> <option value='28'>28</option> <option value='29'>29</option> <option value='30'>30</option> <option value='31'>31</option> </select>
</td><td align=left > Year(yyyy)<input type=text name=year size=4 value=2005> <input type=submit value=Submit> </table> </form>
Tested in June month
for($i=0;$i<=11;$i++){
$month=date('M',strtotime("first day of -$i month")); // Month name with 3 letters
echo $month ."<br>";
}
?>
Output is here
Jun
May
Apr
Mar
Feb
Jan
Dec
Nov
Oct
Sep
Aug
Jul
<?php
echo "<select name=month>";
for($i=0;$i<=11;$i++){
$month=date('F',strtotime("first day of -$i month")); // Month full name
echo "<option value=$month>$month</option> ";
}
echo "</select>";
?>
June
May
April
March
February
January
December
November
October
September
August
July
<?php
//Listing next 5 years starting from present year
echo "<select name=year>";
for($i=0;$i<=5;$i++){
$year=date('Y',strtotime("last day of +$i year"));
echo "<option name='$year'>$year</option>";
}
echo "</select>";
?>
$todo=$_POST['todo'];
if(isset($todo) and $todo=="submit"){
$month=$_POST['month'];
$dt=$_POST['dt'];
$year=$_POST['year'];
$date_value="$month/$dt/$year";
echo "mm/dd/yyyy format :$date_value<br>";
$date_value="$year-$month-$dt";
echo "YYYY-mm-dd format :$date_value<br>";
}
?>
<form method=post name=f1 action=''><input type=hidden name=todo value=submit>
<table border="0" cellspacing="0" >
<tr><td align=left >
<select name=month value=''>Select Month</option> <option value='01'>January</option> <option value='02'>February</option> <option value='03'>March</option> <option value='04'>April</option> <option value='05'>May</option> <option value='06'>June</option> <option value='07'>July</option> <option value='08'>August</option> <option value='09'>September</option> <option value='10'>October</option> <option value='11'>November</option> <option value='12'>December</option> </select>
</td><td align=left >
Date<select name=dt >
<option value='01'>01</option> <option value='02'>02</option> <option value='03'>03</option> <option value='04'>04</option> <option value='05'>05</option> <option value='06'>06</option> <option value='07'>07</option> <option value='08'>08</option> <option value='09'>09</option> <option value='10'>10</option> <option value='11'>11</option> <option value='12'>12</option> <option value='13'>13</option> <option value='14'>14</option> <option value='15'>15</option> <option value='16'>16</option> <option value='17'>17</option> <option value='18'>18</option> <option value='19'>19</option> <option value='20'>20</option> <option value='21'>21</option> <option value='22'>22</option> <option value='23'>23</option> <option value='24'>24</option> <option value='25'>25</option> <option value='26'>26</option> <option value='27'>27</option> <option value='28'>28</option> <option value='29'>29</option> <option value='30'>30</option> <option value='31'>31</option> </select>
</td><td align=left > Year(yyyy)<input type=text name=year size=4 value=2005> <input type=submit value=Submit> </table> </form>
Tested in June month
for($i=0;$i<=11;$i++){
$month=date('M',strtotime("first day of -$i month")); // Month name with 3 letters
echo $month ."<br>";
}
?>
Output is here
Jun
May
Apr
Mar
Feb
Jan
Dec
Nov
Oct
Sep
Aug
Jul
<?php
echo "<select name=month>";
for($i=0;$i<=11;$i++){
$month=date('F',strtotime("first day of -$i month")); // Month full name
echo "<option value=$month>$month</option> ";
}
echo "</select>";
?>
June
May
April
March
February
January
December
November
October
September
August
July
<?php
//Listing next 5 years starting from present year
echo "<select name=year>";
for($i=0;$i<=5;$i++){
$year=date('Y',strtotime("last day of +$i year"));
echo "<option name='$year'>$year</option>";
}
echo "</select>";
?>
0 comments:
Post a Comment