3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php echo date('Y-m-d', strtotime('first day of month')); //$date = new DateTime(''); //$date->modify('first day of month'); $date = new DateTime(date('Y-m-d', strtotime('first day of month'))); $i = new DateInterval('P1M'); $end = new DateTime('-1 year'); while ($date >= $end) { echo $date->format('Y F') . PHP_EOL; $date = $date->sub($i); }
Output for 5.3.0 - 7.1.0
1970-01-01
Output for 5.2.0 - 5.2.17
1970-01-01 Fatal error: Class 'DateInterval' not found in /in/pt4vE on line 8
Process exited with code 255.
Output for 5.0.0 - 5.1.6
1970-01-01 Fatal error: Class 'DateTime' not found in /in/pt4vE on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
1970-01-01 Fatal error: Cannot instantiate non-existent class: datetime in /in/pt4vE on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
1970-01-01 Fatal error: Cannot instantiate non-existent class: datetime in /in/pt4vE on line 7