summaryrefslogtreecommitdiff
path: root/ext/date/tests/bug45543.phpt
blob: 42a97ab20c99a19c7f28e10caf54cb6d997da16d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--TEST--
Test for bug #45543: DateTime::setTimezone can not set timezones without ID.
--INI--
date.timezone=UTC
--FILE--
<?php
$test_dates = array(
	'2008-01-01 12:00:00 PDT',
	'2008-01-01 12:00:00 +02:00',
);

foreach ($test_dates as $test_date)
{
	$d1 = new DateTime($test_date);
	$d2 = new DateTime('2008-01-01 12:00:00 UTC');
	echo $d1->format(DATE_ISO8601), PHP_EOL;
	echo $d2->format(DATE_ISO8601), PHP_EOL;
	$tz = $d1->getTimeZone();
	$d2->setTimeZone($tz);
	echo $d1->format(DATE_ISO8601), PHP_EOL;
	echo $d2->format(DATE_ISO8601), PHP_EOL;
	echo PHP_EOL;
}
--EXPECT--
2008-01-01T12:00:00-0700
2008-01-01T12:00:00+0000
2008-01-01T12:00:00-0700
2008-01-01T05:00:00-0700

2008-01-01T12:00:00+0200
2008-01-01T12:00:00+0000
2008-01-01T12:00:00+0200
2008-01-01T14:00:00+0200