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: 2021-04-05 15:18 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: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.4.14 OS: Kubuntu 12.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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>
 [2021-04-05 15:18 UTC] derick@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: derick
 [2021-04-05 15:18 UTC] derick@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php

This got fixed in PHP 7.2.0.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 20:01:35 2025 UTC