Skip to content

Instantly share code, notes, and snippets.

@homleen
Created August 12, 2013 09:01
Show Gist options
  • Save homleen/6209314 to your computer and use it in GitHub Desktop.
Save homleen/6209314 to your computer and use it in GitHub Desktop.
Get dates between two dates.
<?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