Last active
June 7, 2018 10:43
-
-
Save arsenik/647091bc3a9dc3a30ae4cb171f874efc to your computer and use it in GitHub Desktop.
Generate a list of dates for a given date range
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 | |
$s = '2018-01-25'; | |
$e = '2018-02-26'; | |
$interval = \DateInterval::createFromDateString('1 day'); | |
$start_datetime = new \DateTime($s); | |
$end_datetime = new \DateTime($e); | |
$date_period = new \DatePeriod($start_datetime, $interval, $end_datetime->add(new DateInterval('P1D'))); | |
$dates = array(); | |
foreach ($date_period as $i => $p) { | |
echo $p->format('Y-m-d')."\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment