Bug #66651 [Opn->Dup]: DateTime::getTimezone() has invalid values?
| From: | cmb@php.net | Date: | Mon, 27 Jan 2020 13:00:21 +0000 |
| Subject: | Bug #66651 [Opn->Dup]: DateTime::getTimezone() has invalid values? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225143@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66651&edit=1
ID: 66651
Updated by: cmb@php.net
Reported by: blaak at ensemble dot com
Summary: DateTime::getTimezone() has invalid values?
-Status: Open
+Status: Duplicate
Type: Bug
Package: Date/time related
Operating System: Mac OS 10 X
PHP Version: 5.4.24
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Marking as duplicate of request #45543, which is implemented as of
PHP 5.4.26.
Previous Comments:
------------------------------------------------------------------------
[2014-02-06 02:04:26] blaak at ensemble dot com
Description:
------------
---
From manual page: http://www.php.net/datetime.settimezone
---
When I run the test script, $d2 does not have its timezone change, e.g. setTimezone() returns null.
$d1->getTimezone() seems to be valid, although its name via getName() returns "-08:00"
Could this be fixed? Also, it would be nice if all getName() values are valid for the DateTimeZone
constructor as well, e.g. why can't this work:
new DateTimeZone("-08:00")
Test script:
---------------
$d1 = new DateTime('2014-02-02T10:00-0800');
$d2 = new DateTime('2014-02-02T11:58+0000');
$d2->setTimezone($d1->getTimezone());
echo "d2: " . $d2->format(DateTime::W3C) . "\n";
Expected result:
----------------
d2: 2014-02-02-T03:58:00-0800
e.g. the time display is relative to the PST time zone.
Actual result:
--------------
d2: 2014-02-02T11:58:00+00:00
e.g. the timezone did not change, since setTimezone() did not succeed.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66651&edit=1