php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78691 DateTime ->modify incorrect behavior in some time zones
Submitted: 2019-10-18 15:07 UTC Modified: 2019-10-18 15:13 UTC
From: writejohnemail at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.4.0RC4 OS: Linux
Private report: No CVE-ID: None
 [2019-10-18 15:07 UTC] writejohnemail at gmail dot com
Description:
------------
In time zones that make a daylight savings change at midnight, on the day of the daylight savings change, ->modify('-1 second') does not work as expected. America/Santiago, America/Havana, Asia/Tehran, America/Asuncion are a few of the time zones that have this behavior

Test script:
---------------
$timezone = 'America/Santiago';
$dateString = "2020-09-06";
$dt = new \DateTime($dateString);
$dtz = new \DateTimeZone($timezone);
$dt->setTimezone($dtz);

echo 'the start of the day:<br>';
$dt->modify('today');
echo $dt->getTimestamp();

echo '<br><br>the start of the day, minus one second. this is incorrect:<br>';
$dt->modify('-1 second');
echo $dt->getTimestamp();

Expected result:
----------------
1599364799

Actual result:
--------------
1599368399

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-18 15:10 UTC] writejohnemail at gmail dot com
-Status: Open +Status: Closed
 [2019-10-18 15:10 UTC] writejohnemail at gmail dot com
This was a timezonedb issue
 [2019-10-18 15:13 UTC] requinix@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 05:01:30 2024 UTC