Last active
December 14, 2015 04:38
-
-
Save aqlx86/5029165 to your computer and use it in GitHub Desktop.
create 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 | |
function date_range($start, $end, $format = 'Y-m-d') | |
{ | |
$start = DateTime::createFromFormat($format, $start); | |
// add 1 day to include last date | |
$end = DateTime::createFromFormat($format, $end)->modify('+1 day'); | |
$dates = new DatePeriod($start, new DateInterval("P1D"), $end); | |
$range = array(); | |
foreach($dates as $dt) | |
{ | |
$range[] = $dt->format($format); | |
} | |
return $range; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment