3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $tz = new DateTimeZone('-09:00'); $dbTz = new DateTimeZone('+00:00'); $date = new DateTimeImmutable('2015-09-01+00:00', $tz); var_dump($date); $date = $date->setTimezone($tz); var_dump($date); $date = $date->setTimezone($dbTz); var_dump($date);
based on 68n16
Output for 7.0.20, 7.1.5 - 7.2.0
object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2015-09-01 00:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTimeImmutable)#4 (3) { ["date"]=> string(26) "2015-08-31 15:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "-09:00" } object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2015-09-01 00:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" }
Output for 5.5.24 - 7.0.6, 7.1.0
object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2015-09-01 00:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTimeImmutable)#4 (3) { ["date"]=> string(26) "2015-08-31 15:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "-09:00" } object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2015-08-31 15:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" }
Output for 5.3.20 - 5.4.45
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (-09:00)' in /in/K2VhP:3 Stack trace: #0 /in/K2VhP(3): DateTimeZone->__construct('-09:00') #1 {main} thrown in /in/K2VhP on line 3
Process exited with code 255.