Last active
December 20, 2015 18:58
-
-
Save morganestes/6179426 to your computer and use it in GitHub Desktop.
Cheaters to build forms with dates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <select id="exp-month" name="exp-month" class="span2"> | |
| <option>Month</option> | |
| <?php | |
| $months = array( | |
| 1 => 'Jan', | |
| 2 => 'Feb', | |
| 3 => 'Mar', | |
| 4 => 'Apr', | |
| 5 => 'May', | |
| 6 => 'June', | |
| 7 => 'July', | |
| 8 => 'Aug', | |
| 9 => 'Sept', | |
| 10 => 'Oct', | |
| 11 => 'Nov', | |
| 12 => 'Dec', | |
| ); | |
| for ($month = 1; $month <= 12; $month ++) { | |
| $month_name = $months[$month]; | |
| $month = sprintf("%02s", $month); | |
| echo "<option value='$month'>$month — $month_name</option>\n"; | |
| } | |
| ?> | |
| </select> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <select id="exp-year" name="exp-year" class="span1"> | |
| <option>Year</option> | |
| <?php | |
| $this_year = date('Y'); | |
| for( $year = $this_year; $year <= $this_year + 12; $year++ ) | |
| echo "<option value='$year'>$year</option>"; | |
| ?> | |
| </select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment