Created
February 6, 2013 10:03
-
-
Save ozh/4721571 to your computer and use it in GitHub Desktop.
Generate list of all 365 days in PHP (aka strtotime() fun)
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 | |
$now = time(); | |
$a_year_later = strtotime('+1 Year', $now); | |
$all_days = array(); | |
// starting today | |
$next = strtotime('+1 Day', strtotime('-1 Day', $now)); | |
// increment day till a year has passed | |
while( 1 ){ | |
if( $next > $a_year_later ) | |
break 1; | |
$all_days[] = date( 'Y-m-d', $next ); | |
$next = strtotime( '+1 Day', $next ); | |
} | |
// result | |
print_r( $all_days ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment