Bug #74691 [Nab]: Novosibirsk Data Time Anomaly
| From: | heiglandreas@php.net | Date: | Wed, 07 Jun 2017 20:13:06 +0000 |
| Subject: | Bug #74691 [Nab]: Novosibirsk Data Time Anomaly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209407@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74691&edit=1
ID: 74691
Updated by: heiglandreas@php.net
Reported by: karpulix at ya dot ru
Summary: Novosibirsk Data Time Anomaly
Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: All
PHP Version: 7.1.5
Block user comment: N
Private report: N
New Comment:
No. It's not. Due to the Timezone change there where about 3600 seconds less than you are
expectingâ¦
Previous Comments:
------------------------------------------------------------------------
[2017-06-06 05:56:49] karpulix at ya dot ru
Because regardless of the time zone in the period beetween from 02.06.2015 to 02.06.2017 should be
the same number of seconds. This is an axiom. No?
------------
ÐоÑÐ¾Ð¼Ñ ÑÑо незавиÑимо оÑ
ÑаÑового поÑÑа в пÑомежÑÑке
Ð¾Ñ 02.06.2015 до 02.06.2017 должно бÑÑÑ
одинаковое колиÑеÑÑво
ÑекÑнд. ÐÑо акÑиома.
------------------------------------------------------------------------
[2017-06-04 08:58:29] heiglandreas@php.net
Why do you think the diff doesn't provide the data correctly? After all there IS one hour
missing in the diff.
You might want something different from it but that's a different story. The difference between
anytime on the 2nd of June 2015 in "Asia/Novosibirsk" and the same time on the 2nd of June
2017 in Asia/Novosibirsk is 1 year, 11 months, 30 days and 23 hours.
So I'd really be interested why you think it doesn't "provide the data
correctly"
------------------------------------------------------------------------
[2017-06-04 08:12:47] karpulix at ya dot ru
But in fact diff does not provide the data correctly. Maybe need to fix the problem at the level of
the environment?
-----------
Ðо ÑакÑиÑеÑки diff
пÑедоÑÑавлÑÐµÑ Ð½ÐµÐ²ÐµÑнÑе
даннÑе. ÐÐ¾Ð¶ÐµÑ Ð±ÑÑÑ Ð½Ñжно
иÑпÑавлÑÑÑ Ð¿ÑÐ¾Ð±Ð»ÐµÐ¼Ñ Ð½Ð°
ÑÑовне окÑÑжениÑ?
------------------------------------------------------------------------
[2017-06-04 07:53:29] heiglandreas@php.net
The diff method works pretty well, you are only looking at a fraction of the result though.
When you look at https://3v4l.org/6eiD6 you will notice that
the difference is 1 year, 11 months, 30 days and 23 hours. Due to the DST-change it's 1 hour
short of being two years!
------------------------------------------------------------------------
[2017-06-02 12:14:36] karpulix at ya dot ru
Because of this, the method works incorrectly "diff" from "DateTime class"
-----
Ðз-за ÑÑого невеÑно ÑабоÑаеÑ
меÑод "diff" клаÑÑа DateTime
//correct:
$dataTimeZone = new DateTimeZone("Europe/Moscow");
$datetime = new DateTime('02.06.2015',$dataTimeZone);
$now = new DateTime('02.06.2017',$dataTimeZone);
$interval = $datetime->diff($now);
$fullYear = (int)$interval->format("%Y");
echo $fullYear;
// 2 - its correct
//incorrect
$dataTimeZone = new DateTimeZone("Asia/Novosibirsk");
$datetime = new DateTime('02.06.2015',$dataTimeZone);
$now = new DateTime('02.06.2017',$dataTimeZone);
$interval = $datetime->diff($now);
$fullYear = (int)$interval->format("%Y");
echo $fullYear;
// 1 - its incorrect
------------------------------------------------------------------------
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=74691
--
Edit this bug report at https://bugs.php.net/bug.php?id=74691&edit=1