php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75976 datetime diff has problem in a day in Asia/Tehran Timezone
Submitted: 2018-02-17 07:57 UTC Modified: 2018-02-17 15:43 UTC
From: armin dot 4838 at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.1.14 OS: linux , windows
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: armin dot 4838 at gmail dot com
New email:
PHP Version: OS:

 

 [2018-02-17 07:57 UTC] armin dot 4838 at gmail dot com
Description:
------------
datetime diff return wrong result in date (2018-3-22 - 2018-3-23). it return 23 hours.
in my test this problem is in Asia/Tehran Timezone.
i test several years and all years in this date has same problem except (2000).
also i test in php versions 5.6 and 7.1

Test script:
---------------
$dateStart  = new DateTime('2018-3-22');
$dateEnd    = new DateTime('2018-3-23');

$diff  = $dateStart->diff($dateEnd);
echo $diff->format("%a Day and %h hours %i minutes %s seconds");


Expected result:
----------------
1 Day and 0 hours 0 minutes 0 seconds

Actual result:
--------------
0 Day and 23 hours 0 minutes 0 seconds

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-17 15:43 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-02-17 15:43 UTC] requinix@php.net
Asia/Tehran begins DST on March 22nd 2018 at midnight. That day will only be 23 hours long.
https://www.timeanddate.com/time/change/iran/tehran
https://3v4l.org/ISLGP

If you construct the dates so that they do not include the skipped time between 00:00 and 01:00 then you will see a full day in the diff.
https://3v4l.org/4thuL
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 14:01:33 2025 UTC