Bug #64653 [Ver->Csd]: Subtraction of DateInterval yields wrong result.

From: Date: Mon, 05 Apr 2021 15:18:19 +0000
Subject: Bug #64653 [Ver->Csd]: Subtraction of DateInterval yields wrong result.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233164@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64653&edit=1

 ID:                 64653
 Updated by:         derick@php.net
 Reported by:        eugen dot artus at gmx dot net
 Summary:            Subtraction of DateInterval yields wrong result.
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            Date/time related
 Operating System:   Kubuntu 12.04
 PHP Version:        5.4.14
-Assigned To:        
+Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2016-06-14 10:53:25] cmb@php.net

Verified: <https://3v4l.org/LpEF6>

------------------------------------------------------------------------
[2013-04-16 21:47:25] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=64653&edit=1


Thread (3 messages)

« previous php.bugs (#233164) next »