Bug #76032 [NEW]: DateTime->diff having issues with leap days
| From: | simon at welsh-au dot com | Date: | Wed, 28 Feb 2018 22:40:57 +0000 |
| Subject: | Bug #76032 [NEW]: DateTime->diff having issues with leap days | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-214155@lists.php.net to get a copy of this message | ||
From: simon at welsh-au dot com
Operating system: Linux
PHP version: 7.2.2
Package: Date/time related
Bug Type: Bug
Bug description:DateTime->diff having issues with leap days
Description:
------------
When in a timezone that's ahead of UTC, DateTime->diff seems to have
issues when the starting date falls on a leap day in UTC.
In the test script, changing the dates from March 1 to March 2 has both
var_dump calls showing 10.
Test script:
---------------
<?php
date_default_timezone_set('UTC');
$d = new DateTime('2008-03-01');
$a = new DateTime('2018-03-01');
var_dump($d->diff($a)->y);
date_default_timezone_set('Europe/Amsterdam');
$d = new DateTime('2008-03-01');
$a = new DateTime('2018-03-01');
var_dump($d->diff($a)->y);
Expected result:
----------------
int(10)
int(10)
Actual result:
--------------
int(10)
int(9)
--
Edit bug report at https://bugs.php.net/bug.php?id=76032&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76032&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76032&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76032&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76032&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76032&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76032&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76032&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76032&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76032&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76032&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76032&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76032&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76032&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76032&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76032&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76032&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76032&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76032&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76032&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76032&r=mysqlcfg