|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74572 Wrong comparison result
Submitted: 2017-05-11 14:45 UTC Modified: 2017-05-11 16:03 UTC
From: bazillio07 at yandex dot ru Assigned: jhdxr (profile)
Status: Closed Package: date_time (PECL)
PHP Version: 7.0Git-2017-05-11 (Git) OS: OS X, Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: bazillio07 at yandex dot ru
New email:
PHP Version: OS:


 [2017-05-11 14:45 UTC] bazillio07 at yandex dot ru
For some reason when we compare 2 dates with 1 sec difference we got a bug in some PHP versions like: `5.6.30`, `7.0.0`, `7.1.16`. In some old verions it not persist in some new again is found.
The link with full test:

Test script:

function getTimezoneDate(DateTime $dateTime)
    return $dateTime->setTimezone(
        DateTime::createFromFormat('O', "+05:00")->getTimezone()

$startDate = new DateTime('@' . 1451674800);

$startDate = getTimezoneDate($startDate);
$endDate = getTimezoneDate(new DateTime('@' . 1451847599));

$startDate->modify('+2 day');

$result1 = $startDate < $endDate;
$result2 = $startDate->getTimestamp() < $endDate->getTimestamp();

echo var_export($result1, true) . "\n" . var_export($result2, true);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-11 16:03 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: jhdxr
 [2017-05-11 16:03 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 11 00:01:26 2023 UTC