Created
February 7, 2018 09:21
-
-
Save dhernandez/92afb9e6070b44c4b9ab1feea9e075be to your computer and use it in GitHub Desktop.
Loop through dates range (PHP)
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
<? | |
$from = new DateTime('2018-01-01'); | |
$to = new DateTime('2018-12-31'); | |
$interval = DateInterval::createFromDateString('1 day'); | |
$period = new DatePeriod($from, $interval, $to); | |
foreach ($period as $day) { | |
echo $day->format('Y-m-d'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment