Bug #66545 [Opn]: DateTime
| From: | cmb@php.net | Date: | Mon, 20 Jun 2016 15:57:13 +0000 |
| Subject: | Bug #66545 [Opn]: DateTime | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201757@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66545&edit=1
ID: 66545
Updated by: cmb@php.net
Reported by: perrier dot p at gmail dot com
Summary: DateTime
Status: Open
Type: Bug
Package: Date/time related
Operating System: Debian 7
PHP Version: 5.5.8
Block user comment: N
Private report: N
New Comment:
> DateInterval fail to calculate number of days and hours
Well, actually it does calculate the number of days and hours (14
days + 23 hours == 15 days - 1 hour), but obviously the values
don't get normalized. Not sure if that's a bug or something to be
documented.
Previous Comments:
------------------------------------------------------------------------
[2014-01-24 21:33:11] s dot wuerker at injc dot net
I've got the same problem with the following code:
http://3v4l.org/ekMU7
------------------------------------------------------------------------
[2014-01-22 14:13:42] perrier dot p at gmail dot com
Description:
------------
DateInterval fail to calculate number of days and hours
http://3v4l.org/ab0Hm#v5424
Test script:
---------------
<?php
$debut = mktime(0, 0, 0, 10, 27, 2013);
$fin = mktime(23, 59, 59, 11, 10, 2013);
$d1 = new DateTime('now',new DateTimeZone('Europe/Paris'));
$d2 = new DateTime('now',new DateTimeZone('Europe/Paris'));
$d1->setTimestamp($debut);
$d2->setTimestamp($fin);
$diff = $d1->diff($d2);
print_r($diff);
Expected result:
----------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 14
[h] => 23
[i] => 59
[s] => 59
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 14
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
Actual result:
--------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 15
[h] => -1
[i] => 59
[s] => 59
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 14
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66545&edit=1