php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79396 DateTime hour incorrect during DST jump forward using setTime
Submitted: 2020-03-18 20:01 UTC Modified: 2020-03-19 07:55 UTC
From: n at tebru dot net Assigned: cmb (profile)
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS: MacOS
Private report: No CVE-ID: None
 [2020-03-18 20:01 UTC] n at tebru dot net
Description:
------------
When using DateTime::setTime() and setting the time to a time that doesn't exist (during a DST jump forward), the timestamp is correct, but the hour does not move forward.

Test script:
---------------
$tz = new DateTimeZone('America/Chicago');
$date = new DateTime('2020-03-08 01:00:00', $tz);
$date->setTime(2,0);
var_dump($date->format(DateTime::ATOM));

Expected result:
----------------
string(25) "2020-03-08T03:00:00-05:00"

Actual result:
--------------
string(25) "2020-03-08T02:00:00-05:00"

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-18 20:12 UTC] n at tebru dot net
The following pull request has been associated:

Patch Name: Fixing issue with setTime during DST jump
On GitHub:  https://github.com/php/php-src/pull/5276
Patch:      https://github.com/php/php-src/pull/5276.patch
 [2020-03-19 07:54 UTC] cmb@php.net
Automatic comment on behalf of nate.brunette@wheniwork.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d70058a139f3a45898e1f270c840fb64ea1a09f0
Log: Fix #79396: DateTime hour incorrect during DST jump forward
 [2020-03-19 07:54 UTC] cmb@php.net
-Status: Open +Status: Closed
 [2020-03-19 07:55 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jul 10 13:01:25 2020 UTC