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('first day of month'); echo $date->format('Y-m-d') . "\n"; echo $date2->format('Y-m-d') . "\n";
based on ZifYg
Output for 5.4.8 - 5.4.45, 5.6.28, 7.0.20 - 7.2.0
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2015-09-01 2015-09-13
Output for 7.0.6
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-04-01 2016-04-03
Output for 7.0.5
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-03
Output for 7.0.4
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-10
Output for 7.0.3
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-18
Output for 7.0.2
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-22
Output for 7.0.1
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-23
Output for 7.0.0
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-27
Output for 5.6.21
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-04-01 2016-04-02
Output for 5.6.20
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-09
Output for 5.6.19
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-07
Output for 5.6.18
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-15
Output for 5.6.17
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-19
Output for 5.6.16
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-28
Output for 5.6.15
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-29
Output for 5.6.14
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-02
Output for 5.6.13
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-15
Output for 5.6.12
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-19
Output for 5.6.11
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-23
Output for 5.6.10
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-25
Output for 5.6.9
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-27
Output for 5.6.8
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-29
Output for 5.5.35
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-04-01 2016-04-22
Output for 5.5.34
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-11
Output for 5.5.33
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-08
Output for 5.5.32
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-17
Output for 5.5.31
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-02-01 2016-02-20
Output for 5.5.30
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-01
Output for 5.5.29
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-16
Output for 5.5.28
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-21
Output for 5.5.27
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-22
Output for 5.5.26
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-26
Output for 5.5.25
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-03-01 2016-03-28
Output for 5.5.24
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2016-04-01 2016-04-23
Output for 5.4.2 - 5.4.7
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2015-09-01 2015-09-27
Output for 5.3.27 - 5.3.29
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF 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 (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4 2015-10-01 2015-10-02