php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64653 Subtraction of DateInterval yields wrong result.
Submitted: 2013-04-16 21:47 UTC Modified: 2016-06-14 10:53 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: eugen dot artus at gmx dot net Assigned:
Status: Verified Package: Date/time related
PHP Version: 5.4.14 OS: Kubuntu 12.04
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: eugen dot artus at gmx dot net
New email:
PHP Version: OS:

 

 [2013-04-16 21:47 UTC] eugen dot artus at gmx dot net
Description:
------------
The test script below prints '2370-01-00' as the result, which is obviously wrong.

Test script:
---------------
<?php
    $date = new \DateTime('2370-01-31');
    echo $date->sub(new \DateInterval('P1M'))->format('Y-m-d'); 
?>


Expected result:
----------------
2369-12-31

Actual result:
--------------
2370-01-00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-14 10:53 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2016-06-14 10:53 UTC] cmb@php.net
Verified: <https://3v4l.org/LpEF6>
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC