3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $val = new DateTime(); var_dump(json_encode($val)); var_dump(json_last_error()); var_dump(PHP_VERSION_ID >= 50500 ? json_last_error_msg() : NULL);
Output for 7.1.0
string(86) "{"date":"2014-04-09 23:02:51.006142","timezone_type":3,"timezone":"Europe\/Amsterdam"}" int(0) string(8) "No error"
Output for 5.5.14 - 7.0.14
string(86) "{"date":"2014-04-09 23:02:51.000000","timezone_type":3,"timezone":"Europe\/Amsterdam"}" int(0) string(8) "No error"
Output for 5.5.0 - 5.5.13
string(79) "{"date":"2014-04-09 23:02:51","timezone_type":3,"timezone":"Europe\/Amsterdam"}" int(0) string(8) "No error"
Output for 5.4.30 - 5.4.45
string(86) "{"date":"2014-04-09 23:02:51.000000","timezone_type":3,"timezone":"Europe\/Amsterdam"}" int(0) NULL
Output for 5.3.0 - 5.4.29
string(79) "{"date":"2014-04-09 23:02:51","timezone_type":3,"timezone":"Europe\/Amsterdam"}" int(0) NULL
Output for 5.2.0 - 5.2.17
string(2) "{}" Fatal error: Call to undefined function json_last_error() in /in/31YAE on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/31YAE on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/31YAE on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/31YAE on line 2