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 isSerializable( $var ) { try { serialize( $var ); return TRUE; } catch( Exception $e ) { return FALSE; } } var_dump( serialize( new DateTime() ) ); // bool(true)
Output for 7.1.0
{"date":"2014-06-19 23:15:31.004015","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" string(128) "O:8:"DateTime":3:{s:4:"date";s:26:"2014-06-19 23:15:31.004053";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"America/New_York";}"
Output for 5.5.14 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
{"date":"2014-06-19 23:15:31.000000","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" string(128) "O:8:"DateTime":3:{s:4:"date";s:26:"2014-06-19 23:15:31.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"America/New_York";}"
Output for 5.5.0 - 5.5.13
{"date":"2014-06-19 23:15:31","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" string(121) "O:8:"DateTime":3:{s:4:"date";s:19:"2014-06-19 23:15:31";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"America/New_York";}"
Output for 5.4.30 - 5.4.45
{"date":"2014-06-19 23:15:31.000000","timezone_type":3,"timezone":"America\/New_York"} Fatal error: Call to undefined function json_last_error_msg() in /in/iSv3R on line 8
Process exited with code 255.
Output for 5.3.0 - 5.4.29
{"date":"2014-06-19 23:15:31","timezone_type":3,"timezone":"America\/New_York"} Fatal error: Call to undefined function json_last_error_msg() in /in/iSv3R 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/iSv3R on line 7 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/iSv3R on line 7 Fatal error: Call to undefined function json_last_error() in /in/iSv3R on line 8
Process exited with code 255.
Output for 5.1.1 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/iSv3R on line 5
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/iSv3R on line 20
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/iSv3R on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/iSv3R on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '{' in /in/iSv3R on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/iSv3R on line 12
Process exited with code 255.