Created
July 28, 2011 12:44
-
-
Save jenkoian/1111470 to your computer and use it in GitHub Desktop.
Some useful functions for use with dates
This file contains 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 | |
// Get array of months - useful for month dropdown for example | |
function getmonths() { | |
$months = array(); | |
for ($m=1; $m<=12; $m++) { | |
$months[] = date('m', mktime(0,0,0,$m,1)); | |
} | |
return $months; | |
} | |
// Get array of years - useful for year dropdown for example | |
function getYears() { | |
$years = array(); | |
$cutoff = 1910; | |
$now = date("Y"); | |
for ($y=$now; $y>=$cutoff; $y--) { | |
$years[] = $y; | |
} | |
return $years; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment