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"; }
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 8.0.0 - 8.0.12, 8.1rc1 - rc3
int(1) 2010-06-01 2010-06-02 int(2) 2010-06-01 2010-06-02

preferences:
42.49 ms | 460 KiB | 5 Q