mktime, date & last month

Does this happen every month where the previous month is a
day shorter?


time();
1104532200
Fri, 31 Dec 2004 at 22:30:00


mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
1101859200
Wed, 01 Dec 2004 at 00:00:00

Shouldn't it give:
1101772800
Tue, 30 Nov 2004 at 00:00:00
Blue 58 [ Sa, 01 Januar 2005 06:11 ] [ ID #561505 ]

Re: mktime, date & last month

Blue58 [at] set.hut wrote:
> Does this happen every month where the previous month is a
> day shorter?
>
>
> time();
> 1104532200
> Fri, 31 Dec 2004 at 22:30:00
>
>
> mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
> 1101859200
> Wed, 01 Dec 2004 at 00:00:00
>
> Shouldn't it give:
> 1101772800
> Tue, 30 Nov 2004 at 00:00:00

mktime() does count all the secs, minutes, hours, days and months, so if give
a value that exceeds the limit, it will add/remove aproprirate value from the
next higher "value".

So if you have day 31 for a month November, it will remove 30 days and add a
month and result in the first day of December.


//Aho
Shion [ Sa, 01 Januar 2005 15:39 ] [ ID #561659 ]
PHP » alt.php » mktime, date & last month

Vorheriges Thema: Sorting arrays
Nächstes Thema: Re: I Start your own business doing affiliate work. IBQ<rlCr