Bug #64489 [Opn->Csd]: wrong caclulation with date_diff
| From: | heiglandreas@php.net | Date: | Fri, 13 Jan 2017 16:01:12 +0000 |
| Subject: | Bug #64489 [Opn->Csd]: wrong caclulation with date_diff | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206603@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64489&edit=1
ID: 64489
Updated by: heiglandreas@php.net
Reported by: phpbug at samic dot us
Summary: wrong caclulation with date_diff
-Status: Open
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: Linux Ubuntu
PHP Version: 5.4Git-2013-03-22 (snap)
-Assigned To:
+Assigned To: heiglandreas
Block user comment: N
Private report: N
New Comment:
This has been fixed by now. Calculation seems to be consistend by now. Tested on PHP 7.1
Previous Comments:
------------------------------------------------------------------------
[2013-03-22 18:01:11] phpbug at samic dot us
Mr. Schindhelm who had found the similar problem
(http://www.php.net/manual/en/datetime.diff.php#101990) emailed me and said the problem has got
fixed. I'm sorry I didn't check his problem too and just thought it's similar to my
problem.
------------------------------------------------------------------------
[2013-03-22 17:53:44] phpbug at samic dot us
My default timezone is set to "Asia/Tehran"
as I'm here ;)
------------------------------------------------------------------------
[2013-03-22 15:58:55] aharvey@php.net
Which time zone is your PHP installation using â ie what do you get if you echo
date_default_timezone_get()?
------------------------------------------------------------------------
[2013-03-22 12:00:26] phpbug at samic dot us
Description:
------------
date_diff has a problem with a specific date
it doesn't calculate days between two dates correctly
please see the example
( it seems there is a similar problems: http://www.php.net/manual/en/datetime.diff.php#101990
)
Test script:
---------------
$interval = date_diff(date_create('2000-03-21'), date_create('2013-03-21'));
echo $interval->format('%a') . "<br>\n"; // will output 4747
$interval = date_diff(date_create('2000-03-21'), date_create('2013-03-22'));
echo $interval->format('%a') . "<br>\n"; // will output 4749 ---
WRONG!
$interval = date_diff(date_create('2000-03-21'), date_create('2013-03-23'));
echo $interval->format('%a') . "<br>\n"; // will output 4749
$interval = date_diff(date_create('2000-03-21'), date_create('2013-03-24'));
echo $interval->format('%a') . "<br>\n"; // will output 4750
Expected result:
----------------
4747
4748
4749
4750
Actual result:
--------------
4747
4749
4749
4750
the second calculation is wrong
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64489&edit=1