php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71700 Extra day on diff between begin and end of march 2016
Submitted: 2016-03-02 08:48 UTC Modified: 2021-04-06 19:53 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: soullivaneuh at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.6.18 OS: Ubuntu 15.10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: soullivaneuh at gmail dot com
New email:
PHP Version: OS:

 

 [2016-03-02 08:48 UTC] 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)
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-06 19:53 UTC] derick@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: derick
 [2021-04-06 19:53 UTC] derick@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC