Created
August 26, 2019 16:15
-
-
Save davidchc/acc633bc3cacc96a00ade639e76fef0e to your computer and use it in GitHub Desktop.
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 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