3v4l.org

run code in 500+ PHP versions simultaneously
<?php $start = new DateTime('2018-12-31 00:00:00'); $interval = new DateInterval('P1M'); $recurrences = 5; $period = new DatePeriod($start, $interval, $recurrences); assert($recurrences === $period->recurrences, 'The recurrences should match.'); var_dump(array_map(function(DateTime $date) { return $date->format('Y-m-d'); }, iterator_to_array($period)));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.28, 8.5.0 - 8.5.13, 8.6.0
Fatal error: Uncaught AssertionError: The recurrences should match. in /in/kUrfp:9 Stack trace: #0 /in/kUrfp(9): assert(false, 'The recurrences...') #1 {main} thrown in /in/kUrfp on line 9
Process exited with code 255.
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: assert(): The recurrences should match. failed in /in/kUrfp on line 9 array(6) { [0]=> string(10) "2018-12-31" [1]=> string(10) "2019-01-31" [2]=> string(10) "2019-03-03" [3]=> string(10) "2019-04-03" [4]=> string(10) "2019-05-03" [5]=> string(10) "2019-06-03" }

preferences:
17.88 ms | 1168 KiB | 6 Q