3v4l.org

run code in 300+ PHP versions simultaneously
<?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); }
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 ArgumentCountError: DateTime::createFromFormat() expects at least 2 arguments, 1 given in /in/LYQ2J:3 Stack trace: #0 /in/LYQ2J(3): DateTime::createFromFormat('d H:i:s') #1 {main} thrown in /in/LYQ2J on line 3
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
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.5.35, 5.6.7 - 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.4.2 - 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.

preferences:
164.18 ms | 402 KiB | 227 Q