3v4l.org

run code in 200+ 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')); echo json_encode($o); $s = serialize($o); var_dump(isset($o2->_date_time) === false); } check('DateTime'); class A extends DateTime {} check('A');
Output for 7.2.0
{"date":"2014-06-19 23:20:55.002618","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" {"date":"2014-06-20 03:20:55.002661","timezone_type":3,"timezone":"UTC"}bool(true) {"date":"2014-06-20 03:20:55.002672","timezone_type":3,"timezone":"UTC"}bool(true)
Output for 7.1.10
{"date":"2014-06-19 23:20:55.004616","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" {"date":"2014-06-20 03:20:55.004673","timezone_type":3,"timezone":"UTC"}bool(true) {"date":"2014-06-20 03:20:55.004697","timezone_type":3,"timezone":"UTC"}bool(true)
Output for 7.1.7
{"date":"2014-06-19 23:20:55.002615","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" {"date":"2014-06-20 03:20:55.002650","timezone_type":3,"timezone":"UTC"}bool(true) {"date":"2014-06-20 03:20:55.002663","timezone_type":3,"timezone":"UTC"}bool(true)
Output for 7.1.6
{"date":"2014-06-19 23:20:55.009038","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" {"date":"2014-06-20 03:20:55.009098","timezone_type":3,"timezone":"UTC"}bool(true) {"date":"2014-06-20 03:20:55.009118","timezone_type":3,"timezone":"UTC"}bool(true)
Output for 7.1.5
{"date":"2014-06-19 23:20:55.012038","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" {"date":"2014-06-20 03:20:55.012118","timezone_type":3,"timezone":"UTC"}bool(true) {"date":"2014-06-20 03:20:55.012140","timezone_type":3,"timezone":"UTC"}bool(true)
Output for 7.1.0
{"date":"2014-06-19 23:20:55.004150","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" {"date":"2014-06-20 03:20:55.004195","timezone_type":3,"timezone":"UTC"}bool(true) {"date":"2014-06-20 03:20:55.004215","timezone_type":3,"timezone":"UTC"}bool(true)
Output for 5.5.14 - 7.0.20
{"date":"2014-06-19 23:20:55.000000","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" {"date":"2014-06-20 03:20:55.000000","timezone_type":3,"timezone":"UTC"}bool(true) {"date":"2014-06-20 03:20:55.000000","timezone_type":3,"timezone":"UTC"}bool(true)
Output for 5.5.0 - 5.5.13
{"date":"2014-06-19 23:20:55","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" {"date":"2014-06-20 03:20:55","timezone_type":3,"timezone":"UTC"}bool(true) {"date":"2014-06-20 03:20:55","timezone_type":3,"timezone":"UTC"}bool(true)
Output for 5.4.30 - 5.4.45
{"date":"2014-06-19 23:20:55.000000","timezone_type":3,"timezone":"America\/New_York"} Fatal error: Call to undefined function json_last_error_msg() in /in/dXfFL on line 8
Process exited with code 255.
Output for 5.3.0 - 5.4.29
{"date":"2014-06-19 23:20:55","timezone_type":3,"timezone":"America\/New_York"} Fatal error: Call to undefined function json_last_error_msg() in /in/dXfFL 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/dXfFL on line 7 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/dXfFL on line 7 Fatal error: Call to undefined function json_last_error() in /in/dXfFL on line 8
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/dXfFL 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/dXfFL 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/dXfFL 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/dXfFL 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/dXfFL on line 3