3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = new DateTime(); $json = json_encode(array('a' => $a)); var_dump($a); var_dump($json); $b = json_decode($json, true)['a']; var_dump(DateTime::__set_state($b));
based on eqs2s
Output for 7.2.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.006411" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(92) "{"a":{"date":"2015-12-30 18:47:04.006411","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.006411" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.004293" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(92) "{"a":{"date":"2015-12-30 18:47:04.004293","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.004293" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.002928" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(92) "{"a":{"date":"2015-12-30 18:47:04.002928","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.002928" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.012681" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(92) "{"a":{"date":"2015-12-30 18:47:04.012681","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.012681" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.010633" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(92) "{"a":{"date":"2015-12-30 18:47:04.010633","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.010633" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.003997" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(92) "{"a":{"date":"2015-12-30 18:47:04.003997","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.003997" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.28, 7.0.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(92) "{"a":{"date":"2015-12-30 18:47:04.000000","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-12-30 18:47:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.14 - 5.6.23, 7.0.0 - 7.0.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-30 18:47:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(92) "{"a":{"date":"2015-12-30 18:47:03.000000","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-12-30 18:47:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.0 - 5.5.13
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-12-30 18:47:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(85) "{"a":{"date":"2015-12-30 18:47:03","timezone_type":3,"timezone":"Europe\/Amsterdam"}}" object(DateTime)#2 (3) { ["date"]=> string(19) "2015-12-30 18:47:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }