3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $tz1 = new DateTime('now', new DateTimeZone('UTC')); $tz2 = new DateTime('now', new DateTimeZone('Europe/London')); $tz1->setTimeZone('UTC'); $tz2->setTimeZone('UTC'); var_dump($tz1); var_dump($tz2);
Output for 7.1.0
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2013-10-29 19:32:51.006061" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2013-10-29 19:32:51.006090" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.6.28, 7.0.12 - 7.0.14
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2013-10-29 19:32:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2013-10-29 19:32:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 7.0.6
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-21 14:59:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-21 15:59:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 7.0.5
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-14 12:27:20.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-14 13:27:20.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.5.32 - 5.5.33, 5.6.18 - 5.6.19, 7.0.4
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.5.31, 5.6.17, 7.0.1 - 7.0.3
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.5.30, 5.6.15 - 5.6.16, 7.0.0
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for hhvm-3.12.0
Warning: setTimezone() expects parameter 1 to be object, string given in /in/4LT1W on line 6 Warning: setTimezone() expects parameter 1 to be object, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for hhvm-3.10.0
Warning: setTimezone() expects parameter 1 to be object, string given in /in/4LT1W on line 6 Warning: setTimezone() expects parameter 1 to be object, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.6.21
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 17:25:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-02 18:25:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.6.20
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-10 09:30:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-10 10:30:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.44 - 5.4.45, 5.5.29, 5.6.13 - 5.6.14
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:56.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.43, 5.5.27 - 5.5.28, 5.6.10 - 5.6.12
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.41 - 5.4.42, 5.5.25 - 5.5.26, 5.6.9
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.39 - 5.4.40, 5.5.24, 5.6.7 - 5.6.8
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:12:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:12:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.37 - 5.4.38, 5.5.21 - 5.5.23, 5.6.5 - 5.6.6
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:13:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:13:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.35 - 5.4.36, 5.5.18 - 5.5.20, 5.6.3 - 5.6.4
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:13:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:13:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.31 - 5.4.34, 5.5.16, 5.6.0 - 5.6.2
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:13:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:13:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.5.35
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 05:41:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-23 06:41:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.5.34
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 11:43:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-11 12:43:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.30, 5.5.14 - 5.5.15
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-09 17:13:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 17:13:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.28 - 5.4.29, 5.5.12 - 5.5.13
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:03" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:03" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.4.23 - 5.4.27, 5.5.8 - 5.5.11
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:04" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:04" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.28, 5.4.20 - 5.4.22, 5.5.5 - 5.5.7
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:05" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:05" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.27, 5.4.17 - 5.4.19, 5.5.0 - 5.5.4
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:06" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:06" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.23 - 5.3.26, 5.4.13 - 5.4.16
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:07" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:07" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.20 - 5.3.22, 5.4.9 - 5.4.12
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:08" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:08" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.15 - 5.3.19, 5.4.6 - 5.4.8
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:09" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:09" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.12 - 5.3.14, 5.4.2 - 5.4.5
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:10" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:10" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.7 - 5.3.11, 5.4.0 - 5.4.1
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:11" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:11" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.29
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:02" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:02" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.3 - 5.3.6
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:12" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:12" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.3.0 - 5.3.2
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-09 17:13:13" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-09 17:13:13" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
Output for 5.2.0 - 5.2.17
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 6 Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, string given in /in/4LT1W on line 7 object(DateTime)#1 (0) { } object(DateTime)#2 (0) { }
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/4LT1W 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/4LT1W 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/4LT1W on line 3