xref: /PHP-5.4/ext/date/tests/bug42910.phpt (revision e549873c)
1--TEST--
2Bug #42910 (Constructing DateTime with TimeZone Indicator invalidates DateTimeZone)
3--FILE--
4<?php
5	date_default_timezone_set('America/Los_Angeles');
6	$foo = new DateTime('2007-03-11');
7	$bar = new DateTime('2007-03-11T00:00:00-0800');
8
9	print $foo->format(DateTime::ISO8601) . ' - ' .  $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
10	print $bar->format(DateTime::ISO8601) . ' - ' .  $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
11
12	$foo->setDate(2007, 03, 12);
13	$bar->setDate(2007, 03, 12);
14
15	print $foo->format(DateTime::ISO8601) . ' - ' .  $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
16	print $bar->format(DateTime::ISO8601) . ' - ' .  $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
17
18// --------------
19
20    date_default_timezone_set('Australia/Sydney');
21
22    $date= date_create('2007-11-04 12:00:00+0200');
23    var_dump(date_format($date, 'O e'));
24?>
25--EXPECT--
262007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
272007-03-11T00:00:00-0800 - -08:00 - 1173600000
282007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
292007-03-12T00:00:00-0800 - -08:00 - 1173686400
30string(12) "+0200 +02:00"
31