Skip to content

Instantly share code, notes, and snippets.

@muhfaris
Created November 29, 2017 03:49
Show Gist options
  • Save muhfaris/002d423f23a6e4143f71df51192d1cdf to your computer and use it in GitHub Desktop.
Save muhfaris/002d423f23a6e4143f71df51192d1cdf to your computer and use it in GitHub Desktop.
Get range of date
function get_date_range($first, $last,$output_format = 'Y-m-d') {
$days = 86400;
$blok_startDate = array();
$current = strtotime($first);
$last = strtotime($last);
$numday = round(($last - $current) / $days) +1;
for( $d=0; $d < $numday; $d++) {
$blok_startDate[]= '"' . date($output_format, ($current + ($d * $day))) . '"';
}
return $blok_startDate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment