3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $oneMonth = new \DateInterval('P1M'); $startDate = \DateTime::createFromFormat('d H:i:s'); $period = new \DatePeriod($startDate, $oneMonth, 16); foreach($period as $date){ //$date is an instance of \DateTime. I'm just var_dumping it for illustration var_dump($date); }
based on 9HbHY
Output for 7.0.0 - 7.2.0
Warning: DateTime::createFromFormat() expects at least 2 parameters, 1 given in /in/LYQ2J on line 3 Fatal error: Uncaught Exception: DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments. in /in/LYQ2J:4 Stack trace: #0 /in/LYQ2J(4): DatePeriod->__construct(false, Object(DateInterval), 16) #1 {main} thrown in /in/LYQ2J on line 4
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Warning: DateTime::createFromFormat() expects at least 2 parameters, 1 given in /in/LYQ2J on line 3 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/LYQ2J:4 Stack trace: #0 /in/LYQ2J(4): DatePeriod->__construct(false, Object(DateInterval), 16) #1 {main} thrown in /in/LYQ2J on line 4
Process exited with code 255.
Output for 5.3.17 - 5.4.45
Warning: DateTime::createFromFormat() expects at least 2 parameters, 1 given in /in/LYQ2J on line 3 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/LYQ2J:4 Stack trace: #0 /in/LYQ2J(4): DatePeriod->__construct(false, Object(DateInterval), 16) #1 {main} thrown in /in/LYQ2J on line 4
Process exited with code 255.