php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: janne at consilia dot fi
New email:
PHP Version: OS:

 

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

The test script produces the following result:
2018-07-31 
2018-07-01 
2018-06-01


Test script:
---------------
<?php
$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";



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-31 08:25 UTC] peehaa@php.net
-Status: Open +Status: Not a bug
 [2018-07-31 08:25 UTC] peehaa@php.net
June has only 30 days so it overflows into July.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 14:01:30 2024 UTC