3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dt = new DateTime( null ); $serial = serialize( $dt ); var_dump( '1', unserialize( $serial ) ); $test = 'O:8:"DateTime":3:{s:4:"date";s:19:"2014-03-31 14:55:58";s:13:"timezone_type";i:3;s:8:"timezone";s:12:"Europe/Paris";}'; var_dump( '2', unserialize( $test ) ); $test = 'O:8:"DateTime":3:{s:4:"date";s:19:"2014-03-31 14:55:58";s:13:"timezone_type";i:3;s:8:"timezone";s:0:"";}'; var_dump( '3', unserialize( $test ) );
Output for 7.1.0
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 16:07:20.006195" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 14:55:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } Fatal error: Uncaught Error: Invalid serialization data for DateTime object in /in/KJM2Z:13 Stack trace: #0 [internal function]: DateTime->__wakeup() #1 /in/KJM2Z(13): unserialize('O:8:"DateTime":...') #2 {main} thrown in /in/KJM2Z on line 13
Process exited with code 255.
Output for 5.4.30 - 5.4.45, 5.5.14 - 5.6.28, 7.0.0 - 7.0.14
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 16:07:20.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 14:55:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } Fatal error: Invalid serialization data for DateTime object in /in/KJM2Z on line 13
Process exited with code 255.
Output for hhvm-3.12.0 - 3.13.2
Fatal error: Uncaught exception 'Exception' with message '__construct() expects parameter 1 to be string, null given' in /in/KJM2Z:3 Stack trace: #0 /in/KJM2Z(3): DateTime->__construct() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 16:07:20.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 14:55:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone ()' in /in/KJM2Z:13 Stack trace: #0 /in/KJM2Z(13): DateTime->__wakeup() #1 {main}
Process exited with code 255.
Output for 5.4.28 - 5.4.29, 5.5.12 - 5.5.13
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 16:07:20" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 14:55:58" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } Fatal error: Invalid serialization data for DateTime object in /in/KJM2Z on line 13
Process exited with code 255.
Output for 5.3.0 - 5.4.27, 5.5.0 - 5.5.11
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 16:07:20" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 14:55:58" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" }
Process exited with code 139.
Output for 5.2.0 - 5.2.17
string(1) "1" object(DateTime)#2 (0) { } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 14:55:58" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } string(1) "3" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 14:55:58" ["timezone_type"]=> int(3) ["timezone"]=> string(0) "" }
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/KJM2Z on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/KJM2Z on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/KJM2Z on line 3