Bug #76686 [Opn->Nab]: Datetime->sub calculates incorrectly on dates late in a month
| From: | peehaa@php.net | Date: | Tue, 31 Jul 2018 08:25:30 +0000 |
| Subject: | Bug #76686 [Opn->Nab]: Datetime->sub calculates incorrectly on dates late in a month | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216529@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76686&edit=1
ID: 76686
Updated by: peehaa@php.net
Reported by: janne at consilia dot fi
Summary: Datetime->sub calculates incorrectly on dates late
in a month
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
PHP Version: 7.0.31
Block user comment: N
Private report: N
New Comment:
June has only 30 days so it overflows into July.
Previous Comments:
------------------------------------------------------------------------
[2018-07-31 08:01:21] 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";
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76686&edit=1