Skip to content

Instantly share code, notes, and snippets.

@davidchc
Created August 26, 2019 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidchc/acc633bc3cacc96a00ade639e76fef0e to your computer and use it in GitHub Desktop.
Save davidchc/acc633bc3cacc96a00ade639e76fef0e to your computer and use it in GitHub Desktop.
<?php
function getRangeDate($start, $end, $increment = '+1 days') {
$current = strtotime($start);
$end = strtotime($end);
$results = [];
while($current < $end){
$results[] = date('Y-m-d', $current);
$current = strtotime($increment, strtotime(date('Y-m-d', $current)));
}
return $results;
}
$start = date('Y-m-d', strtotime('- 7 day'));
$end = date('Y-m-d');
print_r(getRangeDate($start, $end));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment