<?php
$oneMonth = new \DateInterval('P1M');
$startDate = date('Y-m-d');
$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 TypeError: DatePeriod::__construct() accepts (DateTimeInterface, DateInterval, int [, int]), or (DateTimeInterface, DateInterval, DateTime [, int]), or (string [, int]) as arguments in /in/1EIKA:4
Stack trace:
#0 /in/1EIKA(4): DatePeriod->__construct('2016-03-21', Object(DateInterval), 16)
#1 {main}
thrown in /in/1EIKA on line 4
Process exited with code 255.
Fatal error: Uncaught Exception: DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments. in /in/1EIKA:4
Stack trace:
#0 /in/1EIKA(4): DatePeriod->__construct('2016-03-21', Object(DateInterval), 16)
#1 {main}
thrown in /in/1EIKA on line 4
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 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/1EIKA:4
Stack trace:
#0 /in/1EIKA(4): DatePeriod->__construct('2016-03-21', Object(DateInterval), 16)
#1 {main}
thrown in /in/1EIKA on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 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/1EIKA:4
Stack trace:
#0 /in/1EIKA(4): DatePeriod->__construct('2016-03-21', Object(DateInterval), 16)
#1 {main}
thrown in /in/1EIKA on line 4
Process exited with code 255.
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1EIKA on line 2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1EIKA on line 4
Fatal error: Class 'DateInterval' not found in /in/1EIKA on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1EIKA on line 2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1EIKA on line 4
Fatal error: Cannot instantiate non-existent class: dateinterval in /in/1EIKA on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1EIKA on line 2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1EIKA on line 4
Fatal error: Cannot instantiate non-existent class: dateinterval in /in/1EIKA on line 2