RE: [PHP] mktime() question - SOLVED
| From: | Jay Blanchard | Date: | Fri, 02 Aug 2002 13:59:35 +0000 |
| Subject: | RE: [PHP] mktime() question - SOLVED | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110834@lists.php.net to get a copy of this message | ||
[snip]
I need to subtract months by their abbreviated month name, so shouldn't this
work?
print(date("M", mktime(date("M")-$i));
and if I loop;
Aug
Jul
Jun
May
........
[/snip]
Apparently not. But you can subtract by total hours in a given period, so
for an average I chose 30 days * 24 hours (720);
$i = 36;
$h = 720;
while($i > 0){
print(date("M",
mktime(date("M")-$h)));print(date("Y"));print("<br>");
$i--;
$h = $h + 720;
}
which results in
Jul2002
Jun2002
May2002
Apr2002
Mar2002
Feb2002
Jan2002
Dec2002
Nov2002
Oct2002
Sep2002
Aug2002
Jul2002
Jun2002
May2002
So now all I have to do is sove the year rollover, which I think I can do
the same way. It'd be so much easier if mktime worked as the documentation
said, but after many iterations of different things this is what I was able
to come up with.
Jay
Carpe Ductum - Sieze the tape
*********************************************
* Texas PHP Developers Meeting Spring 2003 *
* T Bar M Resort & Conference Center *
* New Braunfels, Texas *
* Interested? Contact; *
* jay.blanchard@niicommunications.com *
*********************************************