Edit report at https://bugs.php.net/bug.php?id=52480&edit=1
ID: 52480
Updated by: kalle@php.net
Reported by: alex dot joyce at staff dot comcen dot com dot au
Summary: Incorrect difference using DateInterval
-Status: Re-Opened
+Status: Assigned
Type: Bug
Package: Date/time related
Operating System: irrelevant
PHP Version: 7.1
Assigned To: derick
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2017-05-25 23:27:56] michael dot moussa at gmail dot com
I have submitted a PR with a test case for this bug:
https://github.com/php/php-src/pull/2539
------------------------------------------------------------------------
[2017-03-23 17:33:25] heiglandreas@php.net
That (https://3v4l.org/1b6fj) looks like a shift of the month number to me. Derick, could you have a
look at that?
------------------------------------------------------------------------
[2017-03-20 11:44:08] requinix@php.net
Happens for March https://3v4l.org/R3LLN but not May https://3v4l.org/nblYg. DST?
------------------------------------------------------------------------
[2017-03-20 11:22:55] tomasz dot majerski at o2 dot pl
Don't close this issue. PHP 7.0.6 still not getting expected results...
$date_start = '2017-03-01';
$date_end = '2017-03-31';
DateInterval Object
(
[y] => 0
[m] => 1
[d] => 2
[h] => 0
[i] => 0
[s] => 0
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 30
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
------------------------------------------------------------------------
[2017-03-19 09:58:41] heiglandreas@php.net
This seems to be fixed in supported versions of PHP. Therefore I'm closing this issue.
php > $date_start = new DateTime('2010-03-01');
php > $date_end = new DateTime('2010-07-29');
php >
php > $interval = $date_start->diff($date_end);
php >
php > print_r($interval);
DateInterval Object
(
[y] => 0
[m] => 4
[d] => 28
[h] => 0
[i] => 0
[s] => 0
[f] => 0
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 150
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=52480
--
Edit this bug report at https://bugs.php.net/bug.php?id=52480&edit=1