Bug #78452 [Com]: diff makes wrong in hour for Asia/Tehran
| From: | zhangwenchao001 at gmail dot com | Date: | Sat, 31 Aug 2019 14:36:16 +0000 |
| Subject: | Bug #78452 [Com]: diff makes wrong in hour for Asia/Tehran | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222510@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78452&edit=1
ID: 78452
Comment by: zhangwenchao001 at gmail dot com
Reported by: hamedzarei dot 7232 at gmail dot com
Summary: diff makes wrong in hour for Asia/Tehran
Status: Verified
Type: Bug
Package: Date/time related
Operating System: linux
PHP Version: 7.4.0beta4
Block user comment: N
Private report: N
New Comment:
I think this is a problem in daylight saving time.
Test script:
---------------
date_default_timezone_set('Asia/Tehran');
$date1 = new \DateTime('2019-09-21 11:47:24');
$date2 = new \DateTime('2019-08-18 12:47:24');
var_dump($date1->diff($date2));
--------------
object(DateInterval)#3 (16) {
["y"]=>
int(0)
["m"]=>
int(1)
["d"]=>
int(2)
["h"]=>
int(23)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(1)
["days"]=>
int(33)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
Previous Comments:
------------------------------------------------------------------------
[2019-08-28 16:33:39] joe at manvscode dot com
Tehran is in Asia though?
------------------------------------------------------------------------
[2019-08-24 17:37:58] requinix@php.net
https://3v4l.org/94hkf
------------------------------------------------------------------------
[2019-08-24 17:21:27] hamedzarei dot 7232 at gmail dot com
The following patch has been added/updated:
Patch Name: diff_timezone_patch_hamed_01
Revision: 1566667287
URL: https://bugs.php.net/patch-display.php?bug=78452&patch=diff_timezone_patch_hamed_01&revision=1566667287
------------------------------------------------------------------------
[2019-08-24 17:20:51] hamedzarei dot 7232 at gmail dot com
Description:
------------
Diff between 2 DateTimes makes wrong in hour and create -1
I test some cases and think is about setting timezone
Test script:
---------------
date_default_timezone_set('Asia/Tehran');
$date1 = new \DateTime('2019-09-24 11:47:24');
$date2 = new \DateTime('2019-08-21 12:47:24');
var_dump($date1->diff($date2));
Expected result:
----------------
object(DateInterval)#3 (16) {
["y"]=>
int(0)
["m"]=>
int(1)
["d"]=>
int(2)
["h"]=>
int(23)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(1)
["days"]=>
int(33)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
Actual result:
--------------
object(DateInterval)#3 (16) {
["y"]=>
int(0)
["m"]=>
int(1)
["d"]=>
int(3)
["h"]=>
int(-1)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(1)
["days"]=>
int(33)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78452&edit=1