|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-07-30 18:51 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2020-07-30 18:51 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 19:00:02 2025 UTC |
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"