#34898 [Bgs]: strtotime
| From: | alancox+php at gmail dot com | Date: | Mon, 31 Oct 2005 15:34:01 +0000 |
| Subject: | #34898 [Bgs]: strtotime | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-87268@lists.php.net to get a copy of this message | ||
ID: 34898
User updated by: alancox+php at gmail dot com
Reported By: alancox+php at gmail dot com
Status: Bogus
Bug Type: Date/time related
Operating System: Debian Sarge
PHP Version: 5.0.5
New Comment:
Today is Oct. 31st. If I do
date("Y-m-d H:i:s", strtotime("+1 month"));
I get this ...
2005-12-01 10:28:42
There is no reason that strtotime should decide to round November 31st
to December 1st. It is October. If I add one month to October, I get
November.
Previous Comments:
------------------------------------------------------------------------
[2005-10-17 22:40:04] derick@php.net
No bug here.
1. you used the "t" modifier where you should have used "d"
2. There is no november 31st, so that get's rounded up to december 1st
------------------------------------------------------------------------
[2005-10-17 22:24:25] tony2001@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2005-10-17 22:21:14] alancox+php at gmail dot com
Description:
------------
The strtotime function doesn't always add one month when you ask it to.
Reproduce code:
---------------
$date = "2005-10-31 23:59:59";
echo date( "Y-m-t H:i:s", strtotime( "+1 month", strtotime($date) ) );
// 2005-12-31 23:59:59
$date = "2005-10-30 23:59:59";
echo date( "Y-m-t H:i:s", strtotime( "+1 month", strtotime($date) ) );
// 2005-11-30 23:59:59
Expected result:
----------------
Both echos should be 2005-11-30 23:59:59. The first one is incorrect.
Actual result:
--------------
2005-12-31 23:59:592005-11-30 23:59:59
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34898&edit=1