Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function generateDatePicker()
- {
- $months = array(
- 1 => "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December"
- );
- date_default_timezone_set('Asia/Kuala_Lumpur');
- $today = getdate();
- $cur_day = $today['mday'];
- $cur_month = $today['mon'];
- $cur_year = $today['year'];
- // Generate days.
- echo '<select name="day">';
- for ($d = 1; $d <= 31; $d++)
- {
- printf('<option %s>%d</option>',
- $d == $cur_day ? 'selected="selected"' : '',
- $d
- );
- }
- echo '</select> ';
- // Generate months.
- echo '<select name="month">';
- foreach ($months as $key => $value)
- {
- printf('<option %s value="%d">%s</option>',
- $key == $cur_month ? 'selected="selected"' : '',
- $key,
- $value
- );
- }
- echo '</select> ';
- // Generate years.
- echo '<select name="year">';
- for ($y = $cur_year - 20; $y <= $cur_year; $y++)
- {
- printf('<option %s>%d</option>',
- $y == $cur_year ? 'selected="selected"' : '',
- $y
- );
- }
- echo '</select> ';
- }
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>P1Q8</title>
- <link rel="stylesheet" type="text/css" href="style.css" />
- </head>
- <body>
- <?php
- generateDatePicker();
- ?>
- <p>
- [ <a href="index.php">Back</a> ]
- </p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment