php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77741 DateTimeZone/setTimezone returns wrong values
Submitted: 2019-03-14 12:32 UTC Modified: 2021-08-02 13:31 UTC
From: info at akebono dot nl Assigned: cmb (profile)
Status: Not a bug Package: Date/time related
PHP Version: 7.2.16 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: info at akebono dot nl
New email:
PHP Version: OS:

 

 [2019-03-14 12:32 UTC] info at akebono dot nl
Description:
------------
Wrong value output. It does not matter whether TimeZoneNameFrom is set to PST or PDT.

Test script:
---------------
TimeZoneNameFrom = 'PST';
TimeZoneNameTo = 'Europe/Amsterdam';
TimeStr = '2019-3-20 23:59:00';

$convertedTime = date_create($TimeStr, new DateTimeZone($TimeZoneNameFrom))->setTimezone(new DateTimeZone($TimeZoneNameTo))->format("j F H.i");

Expected result:
----------------
21 March 07.59 CET

Actual result:
--------------
21 March 08.59 CET

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-16 15:31 UTC] girgias@php.net
-Assigned To: +Assigned To: derick
 [2019-03-16 15:31 UTC] girgias@php.net
Seems like PHP assumes the transition from Standard time to Summertime occurs at the same time which is not the case with EU/USA.

Can you confirm this @derick?
 [2021-08-02 13:31 UTC] cmb@php.net
-Status: Assigned +Status: Not a bug -Assigned To: derick +Assigned To: cmb
 [2021-08-02 13:31 UTC] cmb@php.net
PST is UTC-8, and Europe/Amsterdam on 2019-3-20T23:59:00 is UTC+1,
so nine hours difference are to be expected.  PDT is also UTC-8
for the date extension, so the actual result is to be expected.
Note also that[1]:

| Please do not use any of the timezones listed here (besides
| UTC), they only exist for backward compatible reasons, and may
| expose erroneous behavior.

[1] <https://www.php.net/manual/en/timezones.others.php>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC