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: 2022-05-20 14:31 UTC
Votes:5
Avg. Score:3.4 ± 1.0
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:4 (80.0%)
From: ewgenij dot starostin at fondsnet dot de Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 7.1.5 OS: Linux
Private report: No CVE-ID: None
 [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

Pull Requests

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:
 [2022-05-20 14:31 UTC] derick@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2022-05-27 13:29 UTC] git@php.net
Automatic comment on behalf of derickr
Revision: https://github.com/php/php-src/commit/6418eba1cd376b82e94a905bf10212126337bcd2
Log: Fixed bug #74671 (DST timezone abbreviation has incorrect offset)
 [2022-05-27 13:29 UTC] git@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC