|  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
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: 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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-09-13 20:52 UTC]
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:

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') {

    $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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-13 20:54 UTC]
-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.
 [2017-01-17 06:35 UTC]
-Status: Assigned +Status: Wont fix
 [2017-01-17 06:35 UTC]
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-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 03 22:05:53 2022 UTC