|
Posted by Michael Fesser on 01/02/08 20:11
..oO(Steve)
>"ashore" <shoreas@gmail.com> wrote in message
>news:d6ba01a0-1681-4377-a6d1-3d75297b7b59@s12g2000prg.googlegroups.com...
>> Guys, the line below just returned "Dec 07" as the date for one month
>> back from today. Hardly life-threatening, but any thoughts?
>>
>> <?php print date("M `y", mktime(0, 0, 0, date("m")-1, date("d"),
>> date("Y")));?>
>
>it's a known bug.
Wrong.
>php uses approximation methods to arrive at a date. most of the time it
>works. essentially, php assumes an average of 30 days in every month.
Wrong again. PHP knows exactly how many days each month has, it just
uses its own way to fix invalid dates like YYYY-11-31 for example.
>you
>can use 12/30/2007 23:59:59 and subtract one month from it and get Nov
>`07...
>
>$date = strtotime('12/30/2007 23:59:59');
>// echo date('M `y', $date); // Nov `07
2007-12-30 - 1m = 2007-11-30
>// now, watch this...
>$date = strtotime('+1 second', $date);
>// you guessed it...Dec `07
2007-12-31 - 1m = 2007-11-31 = 2007-12-1
So where's the problem? PHP's date handling is described in detail in
the manual. It works as intended.
Micha
Navigation:
[Reply to this message]
|