php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66651 DateTime::getTimezone() has invalid values?
Submitted: 2014-02-06 02:04 UTC Modified: 2020-01-27 13:00 UTC
From: blaak at ensemble dot com Assigned: cmb (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.4.24 OS: Mac OS 10 X
Private report: No CVE-ID: None
 [2014-02-06 02:04 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-27 13:00 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2020-01-27 13:00 UTC] cmb@php.net
Marking as duplicate of request #45543, which is implemented as of
PHP 5.4.26.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 03 02:01:27 2024 UTC