|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-31 15:51 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 20:00:01 2025 UTC |
Description: ------------ On the last day of the month all of the below bits of code produce two months in advance as oposed to the next month. So the last day of the month, next month, month +1 etc .. *always* goes two months ahead instead of one. After having checked the documentation, I don't see or understand how string to time if as next month, would output two months. This cleary is not 'next month'. Seems to effect all versions of PHP from 4 to at least 5.2.0 (have not tried and tested 5.2.5). Reproduce code: --------------- $basedate = time(); $date1 = strtotime('next month', $basedate); $date2 = strtotime('+1 month', $basedate); $date3 = strtotime('first month', $basedate); $date4 = mktime(0, 0, 0, date("m")+1, date("d"), date("Y")); $format1 = date('F', $date1); $format2 = date('F', $date2); $format3 = date('F', $date3); $format4 = date('F', $date4); echo $format1; echo $format2; echo $format3; echo $format4; Expected result: ---------------- February February February February Actual result: -------------- March March March March