3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $tests = array( 'first day', 'last day', 'next month', 'first day next month', 'last day next month', 'first day of next month', 'last day of next month' ); foreach ( $tests as $test ) { $result = date_parse( $test ); $rel = $result['relative']; echo $test, "\n- month: ", $rel['month'], '; day: ', $rel['day'], '; first-day-of: ', isset( $rel['first_day_of_month'] ) ? 'true' : 'false', '; last-day-of: ', isset( $rel['last_day_of_month'] ) ? 'true' : 'false', "\n"; $date = new DateTime( '2010-03-06 15:21 UTC' ); echo '- ', $date->format( DateTime::ISO8601 ); $date->modify( $test ); echo ' -> ', $date->format( DateTime::ISO8601 ), "\n\n"; }
Output for 5.3.3 - 5.6.28, 7.0.0 - 7.1.0
first day - month: 0; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-07T15:21:00+0000 last day - month: 0; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-05T15:21:00+0000 next month - month: 1; day: 0; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-06T15:21:00+0000 first day next month - month: 1; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-07T15:21:00+0000 last day next month - month: 1; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-05T15:21:00+0000 first day of next month - month: 1; day: 0; first-day-of: true; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-01T15:21:00+0000 last day of next month - month: 1; day: 0; first-day-of: false; last-day-of: true - 2010-03-06T15:21:00+0000 -> 2010-04-30T15:21:00+0000
Output for hhvm-3.10.0 - 3.12.0
first day - month: 0; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-07T15:21:00+0000 last day - month: 0; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-05T15:21:00+0000 next month - month: 1; day: 0; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-06T15:21:00+0000 first day next month - month: 1; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-07T15:21:00+0000 last day next month - month: 1; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-05T15:21:00+0000 first day of next month - month: 1; day: 0; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-01T15:21:00+0000 last day of next month - month: 1; day: 0; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-30T15:21:00+0000
Output for 5.3.0 - 5.3.2
first day - month: 0; day: 0; first-day-of: true; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-01T15:21:00+0000 last day - month: 0; day: 0; first-day-of: false; last-day-of: true - 2010-03-06T15:21:00+0000 -> 2010-03-31T15:21:00+0000 next month - month: 1; day: 0; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-06T15:21:00+0000 first day next month - month: 1; day: 0; first-day-of: true; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-01T15:21:00+0000 last day next month - month: 1; day: 0; first-day-of: false; last-day-of: true - 2010-03-06T15:21:00+0000 -> 2010-04-30T15:21:00+0000 first day of next month - month: 1; day: 0; first-day-of: true; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-01T15:21:00+0000 last day of next month - month: 1; day: 0; first-day-of: false; last-day-of: true - 2010-03-06T15:21:00+0000 -> 2010-04-30T15:21:00+0000
Output for 5.2.13 - 5.2.17
first day - month: 0; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-07T15:21:00+0000 last day - month: 0; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-05T15:21:00+0000 next month - month: 1; day: 0; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-06T15:21:00+0000 first day next month - month: 1; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-07T15:21:00+0000 last day next month - month: 1; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-05T15:21:00+0000 first day of next month - month: 1; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 Warning: DateTime::modify(): Failed to parse time string (first day of next month) at position 10 (o): The timezone could not be found in the database in /in/1G3hh on line 22 -> 2010-03-06T15:21:00+0000 last day of next month - month: 1; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 Warning: DateTime::modify(): Failed to parse time string (last day of next month) at position 9 (o): The timezone could not be found in the database in /in/1G3hh on line 22 -> 2010-03-06T15:21:00+0000
Output for 5.2.0 - 5.2.12
first day - month: 0; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-07T15:21:00+0000 last day - month: 0; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-03-05T15:21:00+0000 next month - month: 1; day: 0; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-06T15:21:00+0000 first day next month - month: 1; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-07T15:21:00+0000 last day next month - month: 1; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-05T15:21:00+0000 first day of next month - month: 1; day: 1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-07T15:21:00+0000 last day of next month - month: 1; day: -1; first-day-of: false; last-day-of: false - 2010-03-06T15:21:00+0000 -> 2010-04-05T15:21:00+0000
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function date_parse() in /in/1G3hh on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected ')', expecting '(' in /in/1G3hh on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected ')', expecting '(' in /in/1G3hh on line 21
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'('' in /in/1G3hh on line 21
Process exited with code 255.