Bug #67863 [NEW]: datetime->sub does not work well
| From: | teamo dot um1 at mail dot ru | Date: | Tue, 19 Aug 2014 12:09:36 +0000 |
| Subject: | Bug #67863 [NEW]: datetime->sub does not work well | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-187177@lists.php.net to get a copy of this message | ||
From: teamo dot um1 at mail dot ru
Operating system: linux
PHP version: 5.4.31
Package: Date/time related
Bug Type: Bug
Bug description:datetime->sub does not work well
Description:
------------
subsription of months does not work well for the last day of month
Test script:
---------------
$date = new \DateTime();
$date->setDate(2014, 7, 31);
$date->setTime(0,0,0);
print($date->format('Y-m-d'))."\n";
$date->sub(new \DateInterval('P1M'));
print($date->format('Y-m-d'))."\n";
->> 2014-07-31
->> 2014-07-01
must be 2014-06-30
$date->setDate(2014, 8, 31);
->> 2014-08-31
->> 2014-07-31
ok
--
Edit bug report at https://bugs.php.net/bug.php?id=67863&edit=1
--