#49422 [Bgs]: mktime working strange
| From: | rasmus@php.net | Date: | Mon, 31 Aug 2009 14:21:56 +0000 |
| Subject: | #49422 [Bgs]: mktime working strange | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-141745@lists.php.net to get a copy of this message | ||
ID: 49422
Updated by: rasmus@php.net
Reported By: dolby at xpteam dot eu
Status: Bogus
Bug Type: Date/time related
Operating System: gentoo
PHP Version: 5.2.11RC1
New Comment:
Yes, that is the way strtotime works. It uses the standard GNU format
just like your Linux command line date program. You are on Gentoo, so
try this today (Aug.31):
date --date='+1 month' +'Next month is %B'
You will find that it says that next month is October.
You can read lots about it here:
http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html
Pay special attention to section "7.6 Relative items in date strings"
where it says:
"The fuzz in units can cause problems with relative items. For example,
2003-07-31 -1 month might evaluate to 2003-07-01, because 2003-06-31
is an invalid date. To determine the previous month more reliably, you
can ask for the month before the 15th of the current month."
Previous Comments:
------------------------------------------------------------------------
[2009-08-31 09:56:44] dolby at xpteam dot eu
Thank you for your comment.
I have no intention to use bug zone this a a programming support.
But I have come to this "issue" originally by using:
strtotime("+1month");
And using it on 31.08.2009 will produce the:
Thu, 01 Oct 2009 11:52:57 +0200.
Is this really an expected behaviour ?
If so, I am sorry for misusing this bug system.
------------------------------------------------------------------------
[2009-08-31 09:03:43] scottmac@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Since there is no September 31st it becomes October 1st, this is
expected behavior.
------------------------------------------------------------------------
[2009-08-31 08:10:05] dolby at xpteam dot eu
Description:
------------
I am just wondering is this a bug or expected behaviour:
echo date("r", mktime(0,0,0,9,31,2009));
It returns:
Thu, 01 Oct 2009 00:00:00 +0200
but I "expect" i to be:
Wed, 30 Sep 2009 00:00:00 +0200
Maybe I am missing the point, but I always supposed the mktime
considers real dates.
Reproduce code:
---------------
echo date("r", mktime(0,0,0,9,31,2009));
Expected result:
----------------
Wed, 30 Sep 2009 00:00:00 +0200
Actual result:
--------------
Thu, 01 Oct 2009 00:00:00 +0200
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49422&edit=1