Created
August 12, 2013 09:01
-
-
Save homleen/6209314 to your computer and use it in GitHub Desktop.
Get dates between two dates.
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 | |
function datesBetween($start, $end, $format = 'Ymd') | |
{ | |
$output = array(); | |
$startDate = date($format, strtotime($start)); | |
$endDate = date($format, strtotime($end)); | |
$output[] = $startDate; | |
while ( $startDate < $endDate ) | |
{ | |
$startDate = date($format, strtotime('+1 day', strtotime($startDate))); | |
$output[] = $startDate; | |
} | |
return $output; | |
} | |
var_dump(datesBetween('20130801', '20130902')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment