Bug #60960 [Ver->Nab]: Wrong number of days.
| From: | derick@php.net | Date: | Mon, 05 Apr 2021 12:17:04 +0000 |
| Subject: | Bug #60960 [Ver->Nab]: Wrong number of days. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233162@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60960&edit=1
ID: 60960
Updated by: derick@php.net
Reported by: robertosuursoo at yahoo dot com dot br
Summary: Wrong number of days.
-Status: Verified
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Ubuntu 11.04 64bits
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This turned out to be not a bug at all.
2012-10-21 00:00 in the Brazil/East zone does not exist:
Brazil/East Sun Oct 21 02:59:59 2012 UT = Sat Oct 20 23:59:59 2012 -03 isdst=0 gmtoff=-10800
Brazil/East Sun Oct 21 03:00:00 2012 UT = Sun Oct 21 01:00:00 2012 -02 isdst=1 gmtoff=-7200
As Oct 20 23:59:59 is followed by Oct 01:00:00. The result therefore is not a full day, but instead
23 hours:
$ cat /tmp/bug60900.phpt
<?php
date_default_timezone_set("Brazil/East");
$a = new DateTime('2012-10-19');
$b = new DateTime('2012-10-22');
$interval = $a->diff($b);
echo $interval->format('%dD %hH %mM'), "\n";
$a = new DateTime('2012-10-20');
$b = new DateTime('2012-10-22');
$interval = $a->diff($b);
echo $interval->format('%dD %hH %mM'), "\n";
$a = new DateTime('2012-10-21');
$b = new DateTime('2012-10-22');
$interval = $a->diff($b);
echo $interval->format('%dD %hH %mM'), "\n";
Produces:
3D 0H 0M
2D 0H 0M
0D 23H 0M
Previous Comments:
------------------------------------------------------------------------
[2021-03-31 16:35:11] cmb@php.net
For reference: <https://3v4l.org/P5D2u>.
------------------------------------------------------------------------
[2021-03-31 16:34:23] cmb@php.net
Related To: Bug #80913
------------------------------------------------------------------------
[2012-02-03 14:12:17] derick@php.net
This is a bug, it should show 1.
------------------------------------------------------------------------
[2012-02-03 14:10:36] robertosuursoo at yahoo dot com dot br
The function call worked perfectly and solved the problem!
date_default_timezone_set('UTC');
Thank you very much!
------------------------------------------------------------------------
[2012-02-03 13:43:32] robertosuursoo at yahoo dot com dot br
Thanks a lot!
------------------------------------------------------------------------
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=60960
--
Edit this bug report at https://bugs.php.net/bug.php?id=60960&edit=1