note 67391 deleted from function.mktime by bobby
| From: | bobby@php.net | Date: | Tue, 03 Apr 2007 15:19:31 +0000 |
| Subject: | note 67391 deleted from function.mktime by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125051@lists.php.net to get a copy of this message | ||
Note Submitter: nuntius
----
Easy way to get last month.
...and anything else in the date you want. Just introduce the calculation into the mktime function
(note the -1) when building from date().
//Current Date minus one month.
$dateMinusOneMonth = mktime(0, 0, 0, date("m")-1, date("d"),
date("Y"));
$lastmonth = date("M", $dateMinusOneMonth);
echo $lastmonth;
change $dateMinusOneMonth to the below to see it react to a year change (get Dec as last month from
January)
$dateMinusOneMonth = mktime(0, 0, 0, 01-1, 01, 2006);