Bug #74374 [Nab->Dup]: DateTime::sub doesn't work

From: Date: Wed, 05 Apr 2017 11:48:54 +0000
Subject: Bug #74374 [Nab->Dup]: DateTime::sub doesn't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208333@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74374&edit=1 ID: 74374 Updated by: requinix@php.net Reported by: dualsword at mail dot ru Summary: DateTime::sub doesn't work -Status: Not a bug +Status: Duplicate Type: Bug Package: Date/time related Operating System: ubuntu 16.04 Desktop PHP Version: 7.1.3 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2017-04-05 11:32:42] derick@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 '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:16:34] dualsword at mail dot ru Description: ------------ --- 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' => object(DateTime)[1] 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' => object(DateTime)[1] public 'date' => string '2011-03-27 03:59:59.000000' (length=26) public 'timezone_type' => int 3 public 'timezone' => string 'Europe/Moscow' (length=13) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74374&edit=1

« previous php.bugs (#208333) next »