<?php
$date = new DateTime('1st day of last month');
$i = new DateInterval('P1M');
$end = new DateTime('-1 year');
while ($date >= $end) {
echo $date->format('Y F') . PHP_EOL;
$date = $date->sub($i);
}
Fatal error: Uncaught DateMalformedStringException: Failed to parse time string (1st day of last month) at position 0 (1): Unexpected character in /in/BIs8F:2
Stack trace:
#0 /in/BIs8F(2): DateTime->__construct('1st day of last...')
#1 {main}
thrown in /in/BIs8F on line 2
Process exited with code 255.
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Fatal error: Uncaught Exception: Failed to parse time string (1st day of last month) at position 0 (1): Unexpected character in /in/BIs8F:2
Stack trace:
#0 /in/BIs8F(2): DateTime->__construct('1st day of last...')
#1 {main}
thrown in /in/BIs8F on line 2
Process exited with code 255.
Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (1st day of last month) at position 0 (1): Unexpected character in /in/BIs8F:2
Stack trace:
#0 /in/BIs8F(2): DateTime->__construct('1st day of last...')
#1 {main}
thrown in /in/BIs8F on line 2
Process exited with code 255.
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (1st day of last month) at position 0 (1): Unexpected character' in /in/BIs8F:2
Stack trace:
#0 /in/BIs8F(2): DateTime->__construct('1st day of last...')
#1 {main}
thrown in /in/BIs8F on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/BIs8F on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/BIs8F on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/BIs8F on line 2