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: -
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:
Status: Open Package: Date/time related
PHP Version: 5.6.18 OS: Ubuntu 15.10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 04:01:23 2020 UTC