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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: writejohnemail at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 21:01:27 2025 UTC