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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Fri Dec 06 07:01:29 2024 UTC