ID: 42910
User updated by: php at michaelho dot com
Reported By: php at michaelho dot com
Status: Open
Bug Type: Date/time related
Operating System: Mac OS X 10.4.10
PHP Version: 5.2.4
New Comment:
Typo... the first sentence in the third paragraph should read:
"My guess is that **IF** a timezone indicator is passed into the
__construct() method..."
Previous Comments:
------------------------------------------------------------------------
[2007-10-09 23:33:36] php at michaelho dot com
Description:
------------
When creating a new DateTime with an timezone indicator (e.g. "-0800"),
it seems to ignore any DateTimeZone rules as specified either by the
default_timezone setting OR by an explicit DateTimeZone parameter.
Notice that in the example below, the engine no longer applies
DateTimeZone rules for $bar, even though the engine still lists
"America/Los_Angeles" as $bar's DateTimeZone value.
My guess is that a timezone indicator is passed into the __construct()
method, it will be very difficult for the engine to deduce the correct
DateTimeZone rules to use for that DateTime object, and thus, no rules
should be applied after this point.
If this is the case, then at the very least
$bar->getTimezone()->getName() should return something like 'Undefined'
or 'Custom/-0800' or something like that, to correctly indicate it is no
longer using 'America/Los_Angeles' timezone rules.
Reproduce code:
---------------
date_default_timezone_set('America/Los_Angeles');
$foo = new DateTime('2007-03-11');
$bar = new DateTime('2007-03-11T00:00:00-0800');
print $foo->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
print $bar->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
$foo->setDate(2007, 03, 12);
$bar->setDate(2007, 03, 12);
print $foo->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
print $bar->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
Expected result:
----------------
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
Actual result:
--------------
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
2007-03-12T00:00:00-0800 - America/Los_Angeles - 1173686400
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42910&edit=1