Bug #71700 [Opn->Csd]: Extra day on diff between begin and end of march 2016
| From: | derick@php.net | Date: | Tue, 06 Apr 2021 19:53:30 +0000 |
| Subject: | Bug #71700 [Opn->Csd]: Extra day on diff between begin and end of march 2016 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233254@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71700&edit=1
ID: 71700
Updated by: derick@php.net
Reported by: soullivaneuh at gmail dot com
Summary: Extra day on diff between begin and end of march
2016
-Status: Open
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: Ubuntu 15.10
PHP Version: 5.6.18
-Assigned To:
+Assigned To: derick
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.
Fixed for PHP 8.1.
Previous Comments:
------------------------------------------------------------------------
[2016-03-02 08:48:51] soullivaneuh at gmail dot com
Description:
------------
When you try an absolute diff between '2016-03-31' and '2016-03-01', you'll
have an extra day field.
Test script:
---------------
$date1 = new \DateTime('2016-03-01');
$date2 = new \DateTime('2016-03-31');
$diff = date_diff($date1, $date2, true);
var_dump($diff);
Expected result:
----------------
class DateInterval#2 (15) {
public $y =>
int(0)
public $m =>
int(1)
public $d =>
int(0)
public $h =>
int(0)
public $i =>
int(0)
public $s =>
int(0)
public $weekday =>
int(0)
public $weekday_behavior =>
int(0)
public $first_last_day_of =>
int(0)
public $invert =>
int(0)
public $days =>
int(30)
public $special_type =>
int(0)
public $special_amount =>
int(0)
public $have_weekday_relative =>
int(0)
public $have_special_relative =>
int(0)
}
Actual result:
--------------
class DateInterval#2 (15) {
public $y =>
int(0)
public $m =>
int(1)
public $d =>
int(1)
public $h =>
int(0)
public $i =>
int(0)
public $s =>
int(0)
public $weekday =>
int(0)
public $weekday_behavior =>
int(0)
public $first_last_day_of =>
int(0)
public $invert =>
int(0)
public $days =>
int(30)
public $special_type =>
int(0)
public $special_amount =>
int(0)
public $have_weekday_relative =>
int(0)
public $have_special_relative =>
int(0)
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71700&edit=1