3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php var_dump(new DateTime("@" . strtotime("12/21/2017 19:00"), new DateTimeZone("PDT"))); var_dump(new DateTime("@" . strtotime("12/21/2017 19:00"))); var_dump( DateTime::createFromFormat( "Y-m-d H:i:s", date("Y-m-d H:i:s", strtotime("12/21/2017 19:00")), new DateTimeZone("PDT") ) );
based on mRjVi
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-12-21 18:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTime)#1 (3) { ["date"]=> string(26) "2017-12-21 18:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTime)#2 (3) { ["date"]=> string(26) "2017-12-21 19:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "PDT" }
Output for hhvm-3.18.5 - 3.22.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-12-21 18:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTime)#1 (3) { ["date"]=> string(26) "2017-12-21 18:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTime)#2 (3) { ["date"]=> string(26) "2017-12-21 19:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(19) "America/Los_Angeles" }