|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-10-17 22:21 UTC] alancox+php at gmail dot com
Description: ------------ The strtotime function doesn't always add one month when you ask it to. Reproduce code: --------------- $date = "2005-10-31 23:59:59"; echo date( "Y-m-t H:i:s", strtotime( "+1 month", strtotime($date) ) ); // 2005-12-31 23:59:59 $date = "2005-10-30 23:59:59"; echo date( "Y-m-t H:i:s", strtotime( "+1 month", strtotime($date) ) ); // 2005-11-30 23:59:59 Expected result: ---------------- Both echos should be 2005-11-30 23:59:59. The first one is incorrect. Actual result: -------------- 2005-12-31 23:59:592005-11-30 23:59:59 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 00:00:01 2025 UTC |
Today is Oct. 31st. If I do date("Y-m-d H:i:s", strtotime("+1 month")); I get this ... 2005-12-01 10:28:42 There is no reason that strtotime should decide to round November 31st to December 1st. It is October. If I add one month to October, I get November.