ID: 22486 Comment by: tuxedobob at mac dot com Reported By: drwav at hotpop dot com Status: Bogus Bug Type: Date/time related Operating System: Win32 PHP Version: 4.2.3 New Comment:
Yes, it would be more correct. The month after January is Feburary. It follows that adding a month to a day in January should get you a day in February. Likewise, adding a month to March 31 currently gets you May 1st, but should result in April 30. strtotime clearly isn't simply tacking on some number of days, since a month after 1/1 is 2/1 and 2/1 + 1 month is 3/1. It can even handle leap years correctly. It should really do a bit more thinking with regards to this. As for your example, either you're just being a prick, or you've been watching a little too much Pirates of Penzance. Previous Comments: ------------------------------------------------------------------------ [2003-02-28 23:38:30] [EMAIL PROTECTED] But would choosing Feb.28 really be any more correct? If I told you on January 30 that I would come back in exactly one month to beat the crap out of you, when would you think I would show up? ------------------------------------------------------------------------ [2003-02-28 23:34:53] drwav at hotpop dot com when strtotime is asked to create a timestaml +1 month in the future, and is given a timestamp that happens on a day that does not exist in the next month. A timestamp a few days beyond one month in the future is created. Example: <?php $now = strtotime("2003-01-30"); $nextmonth = strtotime("+1 month", $now); print date("Y-m-d", $nextmonth); ?> the output from this script is 2003-03-02 since February has no 30th day, apparently strtotime just adds 30 days to whatever timestamp it is given to go one month in the future, hence March 2nd. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22486&edit=1