xref: /PHP-7.2/ext/date/tests/bug45543.phpt (revision f1d7e3ca)
1--TEST--
2Test for bug #45543: DateTime::setTimezone can not set timezones without ID.
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$test_dates = array(
8	'2008-01-01 12:00:00 PDT',
9	'2008-01-01 12:00:00 +02:00',
10);
11
12foreach ($test_dates as $test_date)
13{
14	$d1 = new DateTime($test_date);
15	$d2 = new DateTime('2008-01-01 12:00:00 UTC');
16	echo $d1->format(DATE_ISO8601), PHP_EOL;
17	echo $d2->format(DATE_ISO8601), PHP_EOL;
18	$tz = $d1->getTimeZone();
19	$d2->setTimeZone($tz);
20	echo $d1->format(DATE_ISO8601), PHP_EOL;
21	echo $d2->format(DATE_ISO8601), PHP_EOL;
22	echo PHP_EOL;
23}
24--EXPECT--
252008-01-01T12:00:00-0700
262008-01-01T12:00:00+0000
272008-01-01T12:00:00-0700
282008-01-01T05:00:00-0700
29
302008-01-01T12:00:00+0200
312008-01-01T12:00:00+0000
322008-01-01T12:00:00+0200
332008-01-01T14:00:00+0200
34