01 <?php
02
03 echo '
04 <p>date picker</p>';
05
06 // create the form
07 echo '
08 <form method="post" action="./">
09 <select name="month">
10 <option>please choose a month</option>';
11
12 // create the month pull-down menu
13 $month = 1;
14 while($month <= 12)
15 {
16 $monthname = date('F', mktime(0,0,0,$month));
17 echo '
18 <option value="'.$month.'">'.$monthname.'</option>';
19 $month++;
20 }
21
22 echo '
23 </select>
24 <select name="day">
25 <option>please choose the day</option>';
26
27 // create the day pull-down menu.
28 $day = 1;
29 while($day <= 31)
30 {
31 echo '
32 <option value="'.$day.'">'.$day.'</option>';
33 $day++;
34 }
35
36 echo '
37 </select>
38 <select name="year">
39 <option>please choose a year</option>';
40
41 // create the year pull-down menu.
42 $year = date('Y');
43 $last_year = $year + 10;
44 while($year <= $last_year)
45 {
46 echo '
47 <option value="'.$year.'">'.$year.'</option>';
48 $year++;
49 }
50
51 echo '
52 </select>
53 <input type="submit" value="submit" />
54 </form>';
55
56 // example output
57 if(isset($_POST['month'])
58 && is_numeric($_POST['month'])
59 && isset($_POST['day'])
60 && is_numeric($_POST['day'])
61 && isset($_POST['year'])
62 && is_numeric($_POST['year']))
63 {
64 $day = $_POST['day'];
65 $month = $_POST['month'];
66 $year = $_POST['year'];
67
68 echo '
69 <p>you selected '.date('l, F \t\he jS Y', mktime(0,0,1,$month,$day,$year)).'.</p>';
70 }
71
72 ?>