<?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);
}
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.
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.