Created
March 5, 2015 08:08
-
-
Save haisum/49704fc2a1944014cae1 to your computer and use it in GitHub Desktop.
Loop through years, months and days in php for dropdown
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
<?php //All months | |
for($i=1;$i<=12;$i++) {?> | |
<option value="<?=$i?>"><?=date("F", strtotime("2001-" . $i . "-25"))?></option> | |
<?php } ?> | |
<?php | |
//past 8 years | |
for($i=0;$i<8;$i++) {?> | |
<option value="<?=$i?>"><?=date("Y", strtotime("-$i years"))?></option> | |
<?php } ?> | |
<?php | |
//days | |
for($i=1;$i<=31;$i++) {?> | |
<option value="<?=$i?>"><?=$i?></option> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment