Bug #75468 [NEW]: Adding +1 month using DateTime, it returns incorrect DateTime.

From: Date: Tue, 31 Oct 2017 09:48:43 +0000
Subject: Bug #75468 [NEW]: Adding +1 month using DateTime, it returns incorrect DateTime.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212385@lists.php.net to get a copy of this message
From: info at milinka dot co dot uk Operating system: any PHP version: Irrelevant Package: Date/time related Bug Type: Bug Bug description:Adding +1 month using DateTime, it returns incorrect DateTime. Description: ------------ NOTE: This bug can replicated only today. 31 Oct 2017. When adding +1 month using DateTime, it returns incorrect DateTime. Code: $begin = new DateTime("now"); $end = clone $begin; $end->modify("+1 month"); var_dump($begin,$end); Outputs dates, where end date is wrong: object(DateTime)#1 (3) { ["date"]=> string(26) "2017-10-31 02:41:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(10) "US/Pacific" } object(DateTime)#2 (3) { ["date"]=> string(26) "2017-12-01 02:41:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(10) "US/Pacific" } Test script: --------------- $begin = new DateTime("now"); $end = clone $begin; $end->modify("+1 month"); var_dump($begin,$end); Expected result: ---------------- object(DateTime)#1 (3) { ["date"]=> string(26) "2017-10-31 02:41:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(10) "US/Pacific" } object(DateTime)#2 (3) { ["date"]=> string(26) "2017-11-30 02:41:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(10) "US/Pacific" } Actual result: -------------- object(DateTime)#1 (3) { ["date"]=> string(26) "2017-10-31 02:41:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(10) "US/Pacific" } object(DateTime)#2 (3) { ["date"]=> string(26) "2017-12-01 02:41:11.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(10) "US/Pacific" } -- Edit bug report at https://bugs.php.net/bug.php?id=75468&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75468&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75468&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75468&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75468&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75468&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75468&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75468&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75468&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75468&r=support Expected behavior: https://bugs.php.net/fix.php?id=75468&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75468&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75468&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75468&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75468&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75468&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75468&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75468&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75468&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75468&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75468&r=mysqlcfg

« previous php.bugs (#212385) next »