#26565 [NEW]: strtotime('next month') resolving to the wrong month

From: Date: Tue, 09 Dec 2003 18:09:41 +0000
Subject: #26565 [NEW]: strtotime('next month') resolving to the wrong month
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-51850@lists.php.net to get a copy of this message
From:             michaelw at darkhorse dot com
Operating system: Mac OS X 10.2.x
PHP version:      4.3.4
PHP Bug Type:     Date/time related
Bug description:  strtotime('next month') resolving to the wrong month

Description:
------------
strtotime adds an extra month when using the phrase 
"this month" or "next month".  Using '+1 months' or '+0 
months' works fine, though.

And, no, I'm not adding a month to 'Jan. 30'.

Reproduce code:
---------------
echo date('Y-m-d', strtotime('last month'));
echo date('Y-m-d', strtotime('this month'));
echo date('Y-m-d', strtotime('next month'));

echo date('Y-m-d', strtotime('-1 months'));
echo date('Y-m-d', strtotime('+0 months'));
echo date('Y-m-d', strtotime('+1 months'));


Expected result:
----------------
2003-11-09
2003-12-09
2004-01-09

2003-11-09
2003-12-09
2004-01-09


Actual result:
--------------
2003-11-09
2004-01-09
2004-02-09

2003-11-09
2003-12-09
2004-01-09


-- 
Edit bug report at http://bugs.php.net/?id=26565&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26565&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26565&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26565&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26565&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26565&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26565&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26565&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26565&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26565&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26565&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26565&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26565&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26565&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26565&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26565&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26565&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26565&r=float


Thread (10 messages)

« previous php.bugs (#51850) next »