Bug #79452 [NEW]: DateTime::diff() generates months differently between time zones
| From: | corey dot taylor dot fl at gmail dot com | Date: | Mon, 06 Apr 2020 01:22:43 +0000 |
| Subject: | Bug #79452 [NEW]: DateTime::diff() generates months differently between time zones | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-226438@lists.php.net to get a copy of this message | ||
From: corey dot taylor dot fl at gmail dot com
Operating system:
PHP version: 7.4.4
Package: Date/time related
Bug Type: Bug
Bug description:DateTime::diff() generates months differently between time zones
Description:
------------
If you create DateTime instances in 'America/New_York' or 'UTC' time
zone and compare them using DateTime::diff() the
months value is
different than using DateTime instances in 'Europe/Berlin' or
'Asia/Tokyo'.
date_default_timezone_set('America/New_York');
$from = new DateTime('2019-06-01');
$to = new DateTime('2019-10-01');
var_dump($from->diff($to)->m);
-- int(4)
date_default_timezone_set('Asia/Tokyo');
$from = new DateTime('2019-06-01');
$to = new DateTime('2019-10-01');
var_dump($from->diff($to)->m);
-- int(3)
The generated days value is the same for both.
If this isn't determined to be an implementation error, then can the
exepcation be documented for DateTime::diff()? Right now, it's
impossible to tell how the DateTime objects are compared between time
zones.
Expected result:
----------------
The generated difference in months is the same for 2 dates is the same
regardless of the time zone they are in.
--
Edit bug report at https://bugs.php.net/bug.php?id=79452&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79452&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79452&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79452&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79452&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79452&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79452&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79452&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79452&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79452&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79452&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79452&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79452&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79452&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79452&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79452&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79452&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79452&r=mysqlcfg