Bug #71913 [Opn->Nab]: extra hour in DateTime modify (Daylight Saving Time problem)
| From: | requinix@php.net | Date: | Tue, 29 Mar 2016 09:13:02 +0000 |
| Subject: | Bug #71913 [Opn->Nab]: extra hour in DateTime modify (Daylight Saving Time problem) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200201@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71913&edit=1
ID: 71913
Updated by: requinix@php.net
Reported by: public at RTLer dot com
Summary: extra hour in DateTime modify (Daylight Saving Time
problem)
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Ubuntu 14.04.4 LTS (GNU/Linux 3.
PHP Version: 7.0.4
Block user comment: N
Private report: N
New Comment:
Asia/Tehran did not have a 2016-03-21 00:00:00 because of the start of daylight savings. 01:00:00 is
the most logical result.
It did have a 2016-03-22 00:00:00 so that is as expected.
Previous Comments:
------------------------------------------------------------------------
[2016-03-29 09:07:12] public at RTLer dot com
Description:
------------
i use php library "Carbon/Carbon" witch use DateTime directly
and when i add one day to this exact day "2016-03-20" with timezone of
"Asia/Tehran" it give one extra hour
but when i add two day it works just fine.
Test script:
---------------
$timezone = new DateTimeZone('Asia/Tehran');
$dayStart = new DateTime('2016-03-20 00:00:00.000000', $timezone);
$dayOne = (new DateTime('2016-03-20 00:00:00.000000', $timezone))->modify('1
day');
$dayTwo = (new DateTime('2016-03-20 00:00:00.000000', $timezone))->modify('2
day');
echo json_encode([
'$dayStart' => $dayStart,
'$dayOne' => $dayOne,
'diff of $dayOne' => $dayStart->diff($dayOne,true),
'$dayTwo' => $dayTwo,
'diff of $dayTwo' => $dayStart->diff($dayTwo,true),
]);
die;
Expected result:
----------------
{
"$dayStart": {
"date": "2016-03-20 00:00:00.000000",
"timezone_type": 3,
"timezone": "Asia\/Tehran"
},
"$dayOne": {
"date": "2016-03-21 00:00:00.000000",
"timezone_type": 3,
"timezone": "Asia\/Tehran"
},
"diff of $dayOne": {
"y": 0,
"m": 0,
"d": 1,
"h": 0,
"i": 0,
"s": 0,
"weekday": 0,
"weekday_behavior": 0,
"first_last_day_of": 0,
"invert": 0,
"days": 1,
"special_type": 0,
"special_amount": 0,
"have_weekday_relative": 0,
"have_special_relative": 0
},
"$dayTwo": {
"date": "2016-03-22 00:00:00.000000",
"timezone_type": 3,
"timezone": "Asia\/Tehran"
},
"diff of $dayTwo": {
"y": 0,
"m": 0,
"d": 2,
"h": 0,
"i": 0,
"s": 0,
"weekday": 0,
"weekday_behavior": 0,
"first_last_day_of": 0,
"invert": 0,
"days": 2,
"special_type": 0,
"special_amount": 0,
"have_weekday_relative": 0,
"have_special_relative": 0
}
}
Actual result:
--------------
{
"$dayStart": {
"date": "2016-03-20 00:00:00.000000",
"timezone_type": 3,
"timezone": "Asia\/Tehran"
},
"$dayOne": {
"date": "2016-03-21 01:00:00.000000",
"timezone_type": 3,
"timezone": "Asia\/Tehran"
},
"diff of $dayOne": {
"y": 0,
"m": 0,
"d": 1,
"h": 1,
"i": 0,
"s": 0,
"weekday": 0,
"weekday_behavior": 0,
"first_last_day_of": 0,
"invert": 0,
"days": 1,
"special_type": 0,
"special_amount": 0,
"have_weekday_relative": 0,
"have_special_relative": 0
},
"$dayTwo": {
"date": "2016-03-22 00:00:00.000000",
"timezone_type": 3,
"timezone": "Asia\/Tehran"
},
"diff of $dayTwo": {
"y": 0,
"m": 0,
"d": 2,
"h": 0,
"i": 0,
"s": 0,
"weekday": 0,
"weekday_behavior": 0,
"first_last_day_of": 0,
"invert": 0,
"days": 2,
"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=71913&edit=1