3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('America/New_York'); $date = new DateTime(); echo json_encode($date,JSON_FORCE_OBJECT); var_dump(json_last_error(), json_last_error_msg()); function check($name) { $o = new $name('now', new DateTimeZone('UTC')); $s = serialize($o); var_dump(isset($o2->_date_time) === false); } check('DateTime'); class A extends DateTime {} check('A');
Output for 7.1.0
{"date":"2014-06-19 23:19:43.004030","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" bool(true) bool(true)
Output for 5.5.14 - 7.0.14
{"date":"2014-06-19 23:19:43.000000","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" bool(true) bool(true)
Output for 5.5.0 - 5.5.13
{"date":"2014-06-19 23:19:43","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" bool(true) bool(true)
Output for 5.4.30 - 5.4.45
{"date":"2014-06-19 23:19:43.000000","timezone_type":3,"timezone":"America\/New_York"} Fatal error: Call to undefined function json_last_error_msg() in /in/PQe7t on line 8
Process exited with code 255.
Output for 5.3.0 - 5.4.29
{"date":"2014-06-19 23:19:43","timezone_type":3,"timezone":"America\/New_York"} Fatal error: Call to undefined function json_last_error_msg() in /in/PQe7t on line 8
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Notice: Use of undefined constant JSON_FORCE_OBJECT - assumed 'JSON_FORCE_OBJECT' in /in/PQe7t on line 7 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/PQe7t on line 7 Fatal error: Call to undefined function json_last_error() in /in/PQe7t on line 8
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/PQe7t on line 5
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function date_default_timezone_set() in /in/PQe7t on line 3
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_default_timezone_set() in /in/PQe7t on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: date_default_timezone_set() in /in/PQe7t on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_default_timezone_set() in /in/PQe7t on line 3