3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = new \DateTime('first day of last month'); $date2 = new \DateTime('last month'); $date2->modify('set first day'); echo $date->format('Y-m-d') . "\n"; echo $date2->format('Y-m-d') . "\n";
Output for 8.3.0 - 8.3.4
Fatal error: Uncaught DateMalformedStringException: DateTime::modify(): Failed to parse time string (set first day) at position 0 (s): The timezone could not be found in the database in /in/ZifYg:4 Stack trace: #0 /in/ZifYg(4): DateTime->modify('set first day') #1 {main} thrown in /in/ZifYg on line 4
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.25, 7.3.8 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17
Warning: DateTime::modify(): Failed to parse time string (set first day) at position 0 (s): The timezone could not be found in the database in /in/ZifYg on line 4 2015-09-01 2015-09-13
Output for 7.0.26 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.7
2015-09-01 2015-09-14

preferences:
247.32 ms | 402 KiB | 363 Q