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', $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/eq1Y1:8 Stack trace: #0 /in/eq1Y1(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/eq1Y1 on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 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/eq1Y1:8 Stack trace: #0 /in/eq1Y1(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/eq1Y1 on line 8
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
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/eq1Y1:8 Stack trace: #0 /in/eq1Y1(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/eq1Y1 on line 8
Process exited with code 255.

preferences:
171.45 ms | 402 KiB | 184 Q