Bug #75038 [Ver]: wrong result of Datetime::add

From: Date: Fri, 11 Aug 2017 13:11:00 +0000
Subject: Bug #75038 [Ver]: wrong result of Datetime::add
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210609@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: derick@php.net Reported by: marco dot delcorto at genesi-software dot it Summary: wrong result of Datetime::add Status: Verified Type: Bug Package: Date/time related Operating System: Windows 7 PHP Version: 5.6.31 Block user comment: N Private report: N New Comment: This is a bug in timelib - in the formatting of timestamps: derick@singlemalt:~/dev/timelib/tests $ ./tester-create-ts "2369-12-31" "" "UTC" TS: 12622694400 | 2369-12-31 00:00:00 UTC UTC derick@singlemalt:~/dev/timelib/tests $ ./tester-render-ts 12622694400 "UTC" TYPE: 3 TS: 12622694400 | 2370-01-00 00:00:00 UTC UTC I have filed a bug upstream: https://github.com/derickr/timelib/issues/17 Previous Comments: ------------------------------------------------------------------------ [2017-08-11 12:14:03] jhdxr@php.net https://3v4l.org/VlkYR ------------------------------------------------------------------------ [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

« previous php.bugs (#210609) next »