php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55686 DateTime object getting stuck on Feb 29th
Submitted: 2011-09-13 20:52 UTC Modified: 2017-01-17 06:35 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: salathe@php.net Assigned: derick (profile)
Status: Wont fix Package: Date/time related
PHP Version: trunk-SVN-2011-09-13 (SVN) OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: salathe@php.net
New email:
PHP Version: OS:

 

 [2011-09-13 20:52 UTC] salathe@php.net
Description:
------------
Some dates falling on February 29th in negative years can not have an interval of 
one day added to them.

The pattern appears to be years of the form -n16, but some years behave as 
expected (e.g. -816 and -416 in the test script below).

Test script:
---------------
<?php

for ($i = -1000; $i < 1000; $i++) {
    $date = new DateTime('midnight', new DateTimeZone('UTC'));
    $date->setDate($i, 2, 29);

    // Rolled over into March, no Feb 29th, skip
    if ($date->format('M') !== 'Feb') {
        continue;
    }

    $next = clone $date;
    $next->add(new DateInterval('P1D'));

    if ($date->format('Y-m-d') === $next->format('Y-m-d')) {
        echo $next->format('Y-m-d l') . PHP_EOL;
    }
}

?>

Expected result:
----------------
No output is expected.

Actual result:
--------------
-0916-02-29 Friday
-0716-02-29 Tuesday
-0616-02-29 Sunday
-0516-02-29 Friday
-0316-02-29 Tuesday
-0216-02-29 Sunday
-0116-02-29 Friday

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-13 20:54 UTC] salathe@php.net
-Assigned To: +Assigned To: derick
 [2012-02-20 21:51 UTC] john at gbd dot co dot uk
Is this important?

Pre-Julian dates were different, Feb had 23 or 24 days rather than the current 
28/29 days, so any date pre 45BC is a bit academic. and probably beyond the scope 
of a PHP date function. http://en.wikipedia.org/wiki/Julian_calendar
 [2017-01-17 06:35 UTC] heiglandreas@php.net
-Status: Assigned +Status: Wont fix
 [2017-01-17 06:35 UTC] heiglandreas@php.net
As this is by now more than 5 years old and a rather edge usecase that seems somewhat academic and also targets an unsupported version of PHP I'm closing this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC