|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74374 DateTime::sub doesn't work
Submitted: 2017-04-05 11:16 UTC Modified: 2017-04-05 11:48 UTC
From: dualsword at mail dot ru Assigned:
Status: Duplicate Package: Date/time related
PHP Version: 7.1.3 OS: ubuntu 16.04 Desktop
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.
Block user comment
Status: Assign to:
Bug Type:
From: dualsword at mail dot ru
New email:
PHP Version: OS:


 [2017-04-05 11:16 UTC] dualsword at mail dot ru
Its work with date '2011-03-27 03:59:59'

Test script:
$d = new DateTime('2011-03-27 03:59:59');
var_dump(['$d is' => $d]);
$d_new = $d->sub(new DateInterval('PT1H'));
var_dump(['$d_new is' => $d_new]);

Expected result:
array (size=1)
  '$d_new is' => 
      public 'date' => string '2011-03-27 02:59:59.000000' (length=26)
      public 'timezone_type' => int 3
      public 'timezone' => string 'Europe/Moscow' (length=13)

Actual result:
array (size=1)
  '$d_new is' => 
      public 'date' => string '2011-03-27 03:59:59.000000' (length=26)
      public 'timezone_type' => int 3
      public 'timezone' => string 'Europe/Moscow' (length=13)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-05 11:32 UTC]
-Summary: DateTime::sub dosnt work +Summary: DateTime::sub doesn't work -Status: Open +Status: Not a bug
 [2017-04-05 11:32 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

'2011-03-27 02:59:59.000000' does not exist, due to a change in timezone rules:

Europe/Moscow  Sat Mar 26 22:59:59 2011 UT = Sun Mar 27 01:59:59 2011 MSK isdst=0 gmtoff=10800
Europe/Moscow  Sat Mar 26 23:00:00 2011 UT = Sun Mar 27 03:00:00 2011 MSK isdst=0 gmtoff=14400

And because of that, PHP overflows to the next hour.
 [2017-04-05 11:48 UTC]
-Status: Not a bug +Status: Duplicate
 [2017-04-05 11:48 UTC]
03:59 UTC+4 -1h should result in 01:59 UTC+3, so I think that makes this an example of the DST transition problem and a duplicate of @heiglandreas's bug #74274.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 03 06:01:27 2023 UTC