in this article, we will learn how to return all dates between two dates in an array


Example 

<?php

$array = array();


//create object of DatePeriod and return array
$date_period = new DatePeriod(
        new DateTime('2020-12-05'), new DateInterval('P1D'), new DateTime('2020-12-10')
);


//extract date from array
foreach ($date_period as $key => $value) {
    $Store = $value->format('Y-m-d');
    $array[] = $Store;
}

print_r($array);
?>

Output:

Array ( [0] => 2020-12-05 [1] => 2020-12-06 [2] => 2020-12-07 [3] => 2020-12-08 [4] => 2020-12-09 )