note 51422 deleted from function.date by betz
| From: | betz@php.net | Date: | Thu, 31 Mar 2005 11:41:15 +0000 |
| Subject: | note 51422 deleted from function.date by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-87249@lists.php.net to get a copy of this message | ||
Note Submitter:
----
It seems that there is some thing wrong with this date( ) function. The following is my code. I want
to get the "month" of last month and the "month" before last month in my
application. However, for the "month" before last month, the result is correct, for the
last month, the result is curent month( obviously, it is wrong ). I did not find this problem before
only today (Mar 30, 2005).
$currentmonth = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d"),
date("Y")));
$lastmonth = date("Y-m-d", mktime(0, 0, 0, date("m")-1, date("d"),
date("Y")));
$pre2month = date("Y-m-d", mktime(0, 0, 0, date("m")-2, date("d"),
date("Y")));
echo ' this month: '.$currentmonth.' || last month'.$lastmonth.' lastlast
month: '.$pre2month;
this month: 2005-03-30 || last month2005-03-02 lastlast month: 2005-01-30
However, if I change date("d") to 1, the results are correct. I think this is perhaps a
small bug in the computation of the time in the mktime( ).