php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71826 DateTime::diff confuse on timezone 'Asia/Tokyo'
Submitted: 2016-03-15 10:25 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sukobuto at gmail dot com Assigned:
Status: Open Package: Date/time related
PHP Version: 5.6.19 OS: CentOS 6.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sukobuto at gmail dot com
New email:
PHP Version: OS:

 

 [2016-03-15 10:25 UTC] sukobuto at gmail dot com
Description:
------------
In some conditions, DateTime::diff makes a mistake on month-section.

For example, the gap of Feb 1 and Mar 1 is 1 month.
But output was "0 month 28 days" in timezone Asia/Tokyo.
("1 month 0 days" in timezone UTC)

Test script:
---------------
https://wandbox.fetus.jp/permlink/zgdq2iE1VuL9zM50

Expected result:
----------------
a: 2015-2-1 <--> 2015-3-1
DateInterval Object
(
    [y] => 0
    [m] => 1
    [d] => 0
    [h] => 0
    [i] => 0
    [s] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 28
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)


b: 2015-3-1 <--> 2015-3-29
DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 28
    [h] => 0
    [i] => 0
    [s] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 28
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)


c: 2015-4-1 <--> 2015-4-29
DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 28
    [h] => 0
    [i] => 0
    [s] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 28
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)

Actual result:
--------------
a(Asia/Tokyo): 2015-2-1 <--> 2015-3-1
DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 28
    [h] => 0
    [i] => 0
    [s] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 28
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)


b(Asia/Tokyo): 2015-3-1 <--> 2015-3-29
DateInterval Object
(
    [y] => 0
    [m] => 1
    [d] => 0
    [h] => 0
    [i] => 0
    [s] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 28
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)


c(Asia/Tokyo): 2015-4-1 <--> 2015-4-29
DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 28
    [h] => 0
    [i] => 0
    [s] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 28
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 28 03:01:23 2020 UTC