Bug #74529 [Opn]: DateTime::diff seems to ignore $absolute = true

From: Date: Tue, 02 May 2017 11:04:37 +0000
Subject: Bug #74529 [Opn]: DateTime::diff seems to ignore $absolute = true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208904@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74529&edit=1 ID: 74529 User updated by: hrovira at seocom dot es Reported by: hrovira at seocom dot es Summary: DateTime::diff seems to ignore $absolute = true Status: Open Type: Bug Package: SPL related Operating System: Ubuntu 16.04.2 LTS PHP Version: 7.1.4 Block user comment: N Private report: N New Comment: Obviously, expected and actual results are switched :( Previous Comments: ------------------------------------------------------------------------ [2017-05-02 11:03:12] hrovira at seocom dot es Description: ------------ DateTime::diff generates different DateInterval results depending on the order, even though $absolute param is set to true. date1->diff(date2, true) is different than date2->diff(date1, true). Please, see test script. Test script: --------------- <?php $date1 = date_create("2014-11-01 00:00:00"); $date2 = date_create("2017-05-01 04:00:00"); $diff1 = $date2->diff($date1, true); $diff2 = $date1->diff($date2, true); echo $diff1->m .' months, '.$diff1->d. ' days'; // outputs: 6 months, 0 days echo $diff2->m .' months, '.$diff2->d. ' days'; // outputs: 5 months, 30 days Expected result: ---------------- 6 months, 0 days 5 months, 30 days Actual result: -------------- 6 months, 0 days 6 months, 0 days ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74529&edit=1

« previous php.bugs (#208904) next »