|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-05-01 20:59 UTC] kalita dot michal at gmail dot com
Description: ------------ Calculated diff is 7 months, 14 days and -1 hour. It doen't make sense, why it is not 7 months, 13 days and 23 hours. This bug is in versions 5.4.45, 5.6.30, 7 and newest. (https://3v4l.org/6OOuG) Test script: --------------- $a = new DateTime("2017-11-17 22:05:26.000000"); $b = new DateTime("2017-04-03 22:29:15.079459"); $diff = $a->diff($b); return $diff->h; Expected result: ---------------- 23 Actual result: -------------- -1 PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 15:00:01 2025 UTC |
I a similar problem with the PHP version 7.4.7 : $currentDateString = '2020-10-21 22:22:59'; $targetDateString = '2020-10-25 21:30:00'; $timezone = new \DateTimeZone('Europe/Paris'); $currentDateTime = new \DateTime($currentDateString, $timezone); $targetDateTime = new \DateTime($targetDateString, $timezone); $dateInterval = $currentDateTime->diff($targetDateTime, TRUE); echo $dateInterval->h; $dateInterval->h value is -1, while the value should be 23. I have the problem on Windows and UNIX.