3v4l.org

run code in 300+ PHP versions simultaneously
<?php $period = new \DatePeriod( new \DateTime('2010-06-01'), new \DateInterval('P1D'), new \DateTime('2010-06-03') ); var_dump($period->recurrences); foreach ($period as $day) { echo $day->format('Y-m-d') . "\n"; } $period = new \DatePeriod( new \DateTime('2010-06-01'), new \DateInterval('P1D'), 1 ); var_dump($period->recurrences); foreach ($period as $day) { echo $day->format('Y-m-d') . "\n"; }
based on J4t0d
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.21, 7.4.0 - 7.4.9, 8.0.0alpha1 - beta1
int(1) 2010-06-01 2010-06-02 int(2) 2010-06-01 2010-06-02