xref: /php-src/ext/date/tests/bug45543.phpt (revision c3dda473)
1--TEST--
2Test for bug #45543: DateTime::setTimezone cannot 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?>
25--EXPECT--
262008-01-01T12:00:00-0700
272008-01-01T12:00:00+0000
282008-01-01T12:00:00-0700
292008-01-01T05:00:00-0700
30
312008-01-01T12:00:00+0200
322008-01-01T12:00:00+0000
332008-01-01T12:00:00+0200
342008-01-01T14:00:00+0200
35