From:             gavinp at tbs dot uk dot com
Operating system: Debian
PHP version:      4.4.8
PHP Bug Type:     Date/time related
Bug description:  Date for next month wrong on last day of Month.

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 bug report at http://bugs.php.net/?id=43997&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43997&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43997&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43997&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43997&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43997&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43997&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43997&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43997&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43997&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43997&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43997&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43997&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43997&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43997&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43997&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43997&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43997&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43997&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43997&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43997&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43997&r=mysqlcfg

Reply via email to