3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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";
based on kBi5X
Output for 7.0.26 - 7.3.1
2015-09-01 2015-09-14
Output for 5.4.0 - 7.0.25
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 5.3.27 - 5.3.29
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-10-01
Output for 5.3.18 - 5.3.26
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-10-01 2015-10-02