|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-10-15 14:46 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2021-10-15 14:46 UTC] requinix@php.net
[2021-10-18 08:07 UTC] victor dot todoran at yahoo dot om
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 01:00:01 2025 UTC |
Description: ------------ DateTime::diff returns different results when called on both objects. Test script: --------------- <?php $date1 = new \DateTime('2015-10-25', new \DateTimeZone('UTC')); $date2 = new \DateTime('2017-10-24', new \DateTimeZone('UTC')); $diff1 = $date1->diff($date2); $diff2 = $date2->diff($date1); echo $diff1->y . ' years ' . $diff1->m . ' months ' . $diff1->d . ' days '; // outputs 1 years 11 months 29 days echo PHP_EOL; echo $diff2->y . ' years ' . $diff2->m . ' months ' . $diff2->d . ' days '; // outputs 1 years 11 months 30 days Expected result: ---------------- 1 years 11 months 29 days 1 years 11 months 29 days or 1 years 11 months 30 days 1 years 11 months 30 days I would expect the number of days to be identical. Actual result: -------------- The number of days differs 1 years 11 months 29 days 1 years 11 months 30 days