3v4l.org

run code in 300+ PHP versions simultaneously
<?php $begin = new DateTime( '2007-10-20' ); $end = new DateTime( '2007-12-31' ); $interval = DateInterval::createFromDateString('1 month'); //$interval = new DateInterval('P1M'); $period = new DatePeriod(DateTime::createFromFormat('m-Y-1', $begin->format('m-Y')), $interval, $end); foreach ( $period as $dt ) { echo $dt->format( "l Y-m-d H:i:s\n" ); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: DatePeriod::__construct() accepts (DateTimeInterface, DateInterval, int [, int]), or (DateTimeInterface, DateInterval, DateTime [, int]), or (string [, int]) as arguments in /in/PYn4g:8 Stack trace: #0 /in/PYn4g(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/PYn4g on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Exception: DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments. in /in/PYn4g:8 Stack trace: #0 /in/PYn4g(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/PYn4g on line 8
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments.' in /in/PYn4g:8 Stack trace: #0 /in/PYn4g(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/PYn4g on line 8
Process exited with code 255.

preferences:
254.05 ms | 402 KiB | 330 Q