/**
* @param \DateTimeImmutable $dateFrom
* @param \DateTimeImmutable $dateTo
*
* @return \DateTimeImmutable[]
* @throws \Exception
*/
function daysRange(\DateTimeImmutable $dateFrom, \DateTimeImmutable $dateTo) : iterable
{
$iter = clone $dateFrom;
while ($iter <= $dateTo) {
yield $iter;
$iter = $iter->add(new \DateInterval('P1D'));
}
}
$days = daysRange(
new \DateTimeImmutable('2020-01-25'),
new \DateTimeImmutable('2020-03-01')
);
foreach ($days as $day) {
echo sprintf("%s\n", $day->format('Y-m-d'));
}