Bug #72291 [Opn]: DateTime miss February 2017

From: Date: Mon, 30 May 2016 10:47:58 +0000
Subject: Bug #72291 [Opn]: DateTime miss February 2017
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201339@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72291&edit=1 ID: 72291 User updated by: gwartur at gmail dot com Reported by: gwartur at gmail dot com Summary: DateTime miss February 2017 Status: Open Type: Bug Package: Date/time related Operating System: Windows NT 6.1 build 7601 PHP Version: 5.6.22 Block user comment: N Private report: N New Comment: Sorry. I'm confused Expected result and Actual result Previous Comments: ------------------------------------------------------------------------ [2016-05-30 10:44:06] gwartur at gmail dot com Description: ------------ I use an object {DateTime} for mass generation intervals in the database. When generating discovered a serious error. By moving the dates in 1 month I have not received February 2017 Test script: --------------- $lastDate = new DateTime(); $lastDate->sub(new DateInterval("P1M")); $generateToThisDate = new DateTime(); $generateToThisDate->add(new DateInterval("P20M")); while ($lastDate < $generateToThisDate) { $lastDate->add(new DateInterval("P1M")); echo $lastDate->format('Y-m-01') . " - " . $lastDate->format('Y-m-t') . "\n"; } Expected result: ---------------- list of new dates: 2016-05-01 - 2016-05-31 2016-06-01 - 2016-06-30 2016-07-01 - 2016-07-31 2016-08-01 - 2016-08-31 2016-09-01 - 2016-09-30 2016-10-01 - 2016-10-31 2016-11-01 - 2016-11-30 2016-12-01 - 2016-12-31 2017-01-01 - 2017-01-31 2017-03-01 - 2017-03-31 2017-04-01 - 2017-04-30 2017-05-01 - 2017-05-31 2017-06-01 - 2017-06-30 2017-07-01 - 2017-07-31 2017-08-01 - 2017-08-31 2017-09-01 - 2017-09-30 2017-10-01 - 2017-10-31 2017-11-01 - 2017-11-30 2017-12-01 - 2017-12-31 2018-01-01 - 2018-01-31 2018-02-01 - 2018-02-28 2018-03-01 - 2018-03-31 2018-04-01 - 2018-04-30 2018-05-01 - 2018-05-31 2018-06-01 - 2018-06-30 Actual result: -------------- list of new dates: 2016-05-01 - 2016-05-31 2016-06-01 - 2016-06-30 2016-07-01 - 2016-07-31 2016-08-01 - 2016-08-31 2016-09-01 - 2016-09-30 2016-10-01 - 2016-10-31 2016-11-01 - 2016-11-30 2016-12-01 - 2016-12-31 2017-01-01 - 2017-01-31 2017-02-01 - 2017-02-28 2017-03-01 - 2017-03-31 2017-04-01 - 2017-04-30 2017-05-01 - 2017-05-31 2017-06-01 - 2017-06-30 2017-07-01 - 2017-07-31 2017-08-01 - 2017-08-31 2017-09-01 - 2017-09-30 2017-10-01 - 2017-10-31 2017-11-01 - 2017-11-30 2017-12-01 - 2017-12-31 2018-01-01 - 2018-01-31 2018-02-01 - 2018-02-28 2018-03-01 - 2018-03-31 2018-04-01 - 2018-04-30 2018-05-01 - 2018-05-31 2018-06-01 - 2018-06-30 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72291&edit=1

« previous php.bugs (#201339) next »