xref: /PHP-7.2/ext/date/tests/bug43003.phpt (revision 89d271a7)
1--TEST--
2Bug #43003 (Invalid timezone reported for DateTime objects constructed using a timestamp)
3--FILE--
4<?php
5date_default_timezone_set('Europe/Oslo');
6
7$oDateTest = new DateTime("@0", new DateTimeZone(date_default_timezone_get()));
8echo $oDateTest->getTimezone()->getName().": " .  $oDateTest->format("Y-m-d H:i:s")."\n";
9
10$oDateTest->setTimezone(new DateTimeZone("UTC"));
11echo $oDateTest->getTimezone()->getName().": " .  $oDateTest->format("Y-m-d H:i:s")."\n";
12
13$oDateTest->setTimezone(new DateTimeZone(date_default_timezone_get()));
14echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d H:i:s")."\n";
15
16$oDateTest = new DateTime("@0");
17echo $oDateTest->getTimezone()->getName().": " .  $oDateTest->format("Y-m-d H:i:s")."\n";
18
19$oDateTest->setTimezone( new DateTimeZone(date_default_timezone_get()));
20echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d H:i:s")."\n";
21?>
22--EXPECT--
23+00:00: 1970-01-01 00:00:00
24UTC: 1970-01-01 00:00:00
25Europe/Oslo: 1970-01-01 01:00:00
26+00:00: 1970-01-01 00:00:00
27Europe/Oslo: 1970-01-01 01:00:00
28