|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76686 Datetime->sub calculates incorrectly on dates late in a month
Submitted: 2018-07-31 08:01 UTC Modified: 2018-07-31 08:25 UTC
From: janne at consilia dot fi Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.0.31 OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: janne at consilia dot fi
New email:
PHP Version: OS:


 [2018-07-31 08:01 UTC] janne at consilia dot fi
The PHP version is actually 7.0.30 (not in the list)

The test script produces the following result:

Test script:
$now = new DateTime('2018-07-31');
echo $now->format('Y-m-d') . "\n";
echo $now->sub(new DateInterval('P1M'))->format('Y-m-d') . "\n";
echo $now->sub(new DateInterval('P1M'))->format('Y-m-d') . "\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-31 08:25 UTC]
-Status: Open +Status: Not a bug
 [2018-07-31 08:25 UTC]
June has only 30 days so it overflows into July.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 00:01:31 2024 UTC