Bug #72291 [NEW]: DateTime miss February 2017
From: gwartur at gmail dot com
Operating system: Windows NT 6.1 build 7601
PHP version: 5.6.22
Package: Date/time related
Bug Type: Bug
Bug description:DateTime miss February 2017
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 bug report at https://bugs.php.net/bug.php?id=72291&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72291&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72291&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72291&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72291&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72291&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72291&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72291&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72291&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72291&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72291&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72291&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72291&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72291&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72291&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72291&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72291&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72291&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72291&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72291&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72291&r=mysqlcfg
Thread (4 messages)
- gwartur at gmail dot com