php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76032 DateTime->diff having issues with leap days for timezones ahead of UTC
Submitted: 2018-02-28 22:40 UTC Modified: 2020-07-19 02:23 UTC
Votes:9
Avg. Score:4.6 ± 0.8
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:6 (85.7%)
From: simon at welsh-au dot com Assigned:
Status: Open Package: Date/time related
PHP Version: 7.2.2 OS: Linux
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: simon at welsh-au dot com
New email:
PHP Version: OS:

 

 [2018-02-28 22:40 UTC] simon at welsh-au dot com
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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-19 02:23 UTC] carusogabriel@php.net
-Summary: DateTime->diff having issues with leap days +Summary: DateTime->diff having issues with leap days for timezones ahead of UTC
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 23:01:24 2020 UTC