php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81287 TimeZone::getTransitions Not Working
Submitted: 2021-07-25 05:10 UTC Modified: 2021-08-08 11:14 UTC
From: eclipsechasers2 at yahoo dot com Assigned: derick (profile)
Status: Duplicate Package: Date/time related
PHP Version: 8.1.0beta1 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: eclipsechasers2 at yahoo dot com
New email:
PHP Version: OS:

 

 [2021-07-25 05:10 UTC] eclipsechasers2 at yahoo dot com
Description:
------------
In PHP8.0 and PHP7.*, the code below produces an array of 5 items, with offset toggling back and forth between -14400 and -18000, and with abbr toggling between EDT and EST. In PHP8.1, it produces an array of 1 item, with an (incorrect) offset of -14400 and (incorrect) abbr of EDT. The timestamps match between 8.1 and other releases, so the problem must be in getTransitions.

I chose 8.1Beta1 as best match; in fact, my version is:
PHP 8.1.0-dev (cli) (built: Jul 24 2021 23:42:29) (NTS Visual C++ 2019 x64)


Test script:
---------------
$timeZone = new DateTimeZone('America/Toronto');
$timestamp = '2008-01-01 12:00:00';
$dtobj = DateTime::createFromFormat('Y-m-d H:i:s', $timestamp);
$tstmp = $dtobj->getTimestamp();
$timestam2 = '2010-01-01 12:00:00';
$dtob2 = DateTime::createFromFormat('Y-m-d H:i:s', $timestam2);
$tstm2 = $dtob2->getTimestamp();
var_dump($tstmp, $tstm2);
$transitions = $timeZone->getTransitions($tstmp, $tstm2);
var_dump($transitions);

Expected result:
----------------
I expect the same result as in other releases - 5 items in array, toggling between EDT and EST, and between an offset of -18000 and -14400.

int(1199217600)
int(1262376000)
array(5) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(1199217600)
    ["time"]=>
    string(24) "2008-01-01T20:00:00+0000"
    ["offset"]=>
    int(-18000)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "EST"
  }
  [1]=>
  array(5) {
    ["ts"]=>
    int(1205046000)
    ["time"]=>
    string(24) "2008-03-09T07:00:00+0000"
    ["offset"]=>
    int(-14400)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(3) "EDT"
  }
  [2]=>
  array(5) {
    ["ts"]=>
    int(1225605600)
    ["time"]=>
    string(24) "2008-11-02T06:00:00+0000"
    ["offset"]=>
    int(-18000)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "EST"
  }
  [3]=>
  array(5) {
    ["ts"]=>
    int(1236495600)
    ["time"]=>
    string(24) "2009-03-08T07:00:00+0000"
    ["offset"]=>
    int(-14400)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(3) "EDT"
  }
  [4]=>
  array(5) {
    ["ts"]=>
    int(1257055200)
    ["time"]=>
    string(24) "2009-11-01T06:00:00+0000"
    ["offset"]=>
    int(-18000)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "EST"
  }
}


Actual result:
--------------
int(1199188800)
int(1262347200)
array(1) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(1199188800)
    ["time"]=>
    string(24) "2008-01-01T12:00:00+0000"
    ["offset"]=>
    int(-14400)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(3) "EDT"
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-26 00:10 UTC] antonino dot spampinato86 at gmail dot com
Since php 8.1 getTransitions returns the break period not all occurrences of transitions.

https://bugs.php.net/bug.php?id=80963
https://3v4l.org/0ZeER#vgit.master_jit
 [2021-08-03 12:39 UTC] ramsey@php.net
-Assigned To: +Assigned To: derick
 [2021-08-03 12:39 UTC] ramsey@php.net
Assigning to Derick. Possible duplicate of #80963.
 [2021-08-08 11:14 UTC] derick@php.net
-Status: Assigned +Status: Duplicate
 [2021-08-08 11:14 UTC] derick@php.net
Duplicate of #80963
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 25 16:03:36 2021 UTC