php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74671 DST timezone abbreviation has incorrect offset
Submitted: 2017-05-29 14:17 UTC Modified: 2017-06-01 18:31 UTC
Votes:3
Avg. Score:2.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: ewgenij dot starostin at fondsnet dot de Assigned:
Status: Open Package: Date/time related
PHP Version: 7.1.5 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-05-29 14:17 UTC] ewgenij dot starostin at fondsnet dot de
Description:
------------
When using a timezone abbreviation (e. g. CEST) instead of a geographical timezone name (e. g. Europe/Berlin) in the DateTimeZone constructor, the resulting time offset is that of the corresponding non-DST timezone, coming up an hour short.

https://3v4l.org/VTI3C

Test script:
---------------
$dt = new DateTime(
    '2017-05-16T10:11:32',
    new DateTimeZone('CEST')
);
var_dump($dt);
var_dump($dt->format('c'));

Expected result:
----------------
object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2017-05-16 10:11:32.000000"
  ["timezone_type"]=>
  int(2)
  ["timezone"]=>
  string(4) "CEST"
}
string(25) "2017-05-16T10:11:32+02:00"

Actual result:
--------------
object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2017-05-16 10:11:32.000000"
  ["timezone_type"]=>
  int(2)
  ["timezone"]=>
  string(4) "CEST"
}
string(25) "2017-05-16T10:11:32+01:00"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-30 09:14 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2017-05-30 09:14 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

From the docs[1]:

| The behavior of timezones not listed here is undefined.

[1] <http://php.net/manual/en/timezones.php>
 [2017-05-30 10:12 UTC] derick@php.net
-Status: Not a bug +Status: Assigned
 [2017-05-30 10:12 UTC] derick@php.net
No, this is a bug. This should work properly. Although it should *not* adjust for DST changeovers.
 [2017-06-01 18:31 UTC] cmb@php.net
-Assigned To: cmb +Assigned To:
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Oct 26 03:01:24 2020 UTC