Bug #79916 [NEW]: Inconsistency when modifying date
| From: | david dot kmenta at me dot com | Date: | Thu, 30 Jul 2020 11:47:03 +0000 |
| Subject: | Bug #79916 [NEW]: Inconsistency when modifying date | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-228344@lists.php.net to get a copy of this message | ||
From: david dot kmenta at me dot com
Operating system:
PHP version: Irrelevant
Package: Date/time related
Bug Type: Bug
Bug description:Inconsistency when modifying date
Description:
------------
When I'm adding (for example) months to the datetime, it shouldn't
matter if I add months one-by-one by calling the "modify" method
multiple times, or at once with one call.
I know it's caused by the February and I don't care if "1 month" means
30, 31, ... days, but I think that there should be a consistent result
regardless the way the "modify" method is used.
Test script:
---------------
$today = new \DateTimeImmutable('2020-01-30 11:00:00');
var_dump($today->modify('+2 months')->format('Y-m-d H:i:s'));
var_dump($today->modify('+1 month')->modify('+1
month')->format('Y-m-d
H:i:s'));
Expected result:
----------------
string(19) "2020-03-30 11:00:00"
string(19) "2020-03-30 11:00:00"
or
string(19) "2020-04-01 11:00:00"
string(19) "2020-04-01 11:00:00"
Actual result:
--------------
string(19) "2020-03-30 11:00:00"
string(19) "2020-04-01 11:00:00"
--
Edit bug report at https://bugs.php.net/bug.php?id=79916&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79916&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79916&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79916&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79916&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79916&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79916&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79916&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79916&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79916&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79916&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79916&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79916&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79916&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79916&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79916&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79916&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79916&r=mysqlcfg