3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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" ); }
based on eq1Y1
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Exception: DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments. in /in/Ebkuf:8 Stack trace: #0 /in/Ebkuf(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/Ebkuf on line 8
Process exited with code 255.
Output for 5.5.24 - 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/Ebkuf:8 Stack trace: #0 /in/Ebkuf(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/Ebkuf on line 8
Process exited with code 255.
Output for 5.3.20 - 5.4.45
Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct(): This constructor accepts either (DateTime, DateInterval, int) OR (DateTime, DateInterval, DateTime) OR (string) as arguments.' in /in/Ebkuf:8 Stack trace: #0 /in/Ebkuf(8): DatePeriod->__construct(false, Object(DateInterval), Object(DateTime)) #1 {main} thrown in /in/Ebkuf on line 8
Process exited with code 255.