Bug #75038 [Opn->Ver]: wrong result of Datetime::add
| From: | jhdxr@php.net | Date: | Fri, 11 Aug 2017 12:14:05 +0000 |
| Subject: | Bug #75038 [Opn->Ver]: wrong result of Datetime::add | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210605@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75038&edit=1
ID: 75038
Updated by: jhdxr@php.net
Reported by: marco dot delcorto at genesi-software dot it
-Summary: datetime error
+Summary: wrong result of Datetime::add
-Status: Open
+Status: Verified
Type: Bug
-Package: *General Issues
+Package: Date/time related
Operating System: Windows 7
PHP Version: 5.6.31
Block user comment: N
Private report: N
New Comment:
https://3v4l.org/VlkYR
Previous Comments:
------------------------------------------------------------------------
[2017-08-04 17:24:04] marco dot delcorto at genesi-software dot it
Description:
------------
---
From manual page: http://www.php.net/datetime.add
---
using the script in the example:
$date = new DateTime('2369-12-30');
$date->add(new DateInterval('P1D'));
echo $date->format('Y-m-d');
the result is '2370-01-00' (wrong), instead of '2369-12-31'
Same problem if we use:
$dateW2 = new DateTime('2369-12-31');
echo date_format($dateW2, 'Y-m-d');
the result is '2370-01-00' (wrong), instead of '2369-12-31'
Test script:
---------------
$date = new DateTime('2369-12-30');
$date->add(new DateInterval('P1D'));
echo $date->format('Y-m-d') . "\n";
$dateW2 = new DateTime('2369-12-31');
echo date_format($dateW2, 'Y-m-d');
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75038&edit=1