php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81560 DateTime-Add($interval) endless loop for dst
Submitted: 2021-10-28 10:37 UTC Modified: 2021-10-28 11:23 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mihailovb at gmail dot com Assigned: derick (profile)
Status: Verified Package: Date/time related
PHP Version: 7.4.25 OS: CentOS7 (and others)
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: mihailovb at gmail dot com
New email:
PHP Version: OS:

 

 [2021-10-28 10:37 UTC] mihailovb at gmail dot com
Description:
------------
PHP 7.4.25 (CentOS), 7.4.3(Ubuntu20.04), 7.2.34(Ubuntu20.04)

It goes into an endless loop when trying to add a 15M interval only when working with "negative" timezones. Doesn't happen for European "pozitive" timezones

Test script:
---------------
<?php
$timezoneDST = new DateTimeZone('America/New_York');
$date = new DateTime("2020-11-01", $timezoneDST);
$dateInterval = new DateInterval('PT15M');
$counter = 0;
while($counter < 500){
    $date->add($dateInterval);
    $counter++;
}
var_dump($date);

Expected result:
----------------
class DateTime#1 (3) {
  public $date =>
  string(26) "2020-11-06 04:00:00.000000"
  public $timezone_type =>
  int(3)
  public $timezone =>
  string(16) "America/New_York"
}

Actual result:
--------------
class DateTime#2 (3) {
  public $date =>
  string(26) "2020-11-01 01:00:00.000000"
  public $timezone_type =>
  int(3)
  public $timezone =>
  string(16) "America/New_York"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-10-28 11:23 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: derick
 [2021-10-28 11:23 UTC] cmb@php.net
This is apparently fixed as of PHP 8.1.0[1]; I'm not sure whether
the fix will be backported.

[1] <https://3v4l.org/1df2R>
 [2021-12-03 08:41 UTC] mihailovb at gmail dot com
Ah, I hope it will be backported, cause after looking into the project and the libraries that are being used, not sure if I'd be able to upgrade to 8.1.
On the bright side, we'd have something less than an year to try and do it.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 29 14:03:34 2022 UTC