#43997 [Opn->Bgs]: Date for next month wrong on last day of Month.

From: Date: Thu, 31 Jan 2008 15:51:15 +0000
Subject: #43997 [Opn->Bgs]: Date for next month wrong on last day of Month.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121823@lists.php.net to get a copy of this message
ID: 43997 Updated by: derick@php.net Reported By: gavinp at tbs dot uk dot com -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: Debian PHP Version: 4.4.8 New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. (And this is expected behavior) Previous Comments: ------------------------------------------------------------------------ [2008-01-31 15:36:03] gavinp at tbs dot uk dot com 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43997&edit=1

« previous php.bugs (#121823) next »