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: 2021-04-06 19:53 UTC
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: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.6.19 OS: CentOS 6.7
Private report: No CVE-ID: None
 [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

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-06 19:53 UTC] derick@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: derick
 [2021-04-06 19:53 UTC] derick@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.

Fixed for PHP 8.1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC