[thelist] wierd results from mktime
Kasimir K
evolt at kasimir-k.fi
Thu Mar 31 08:44:34 CST 2005
David Felton scribeva in 2005-03-31 14:00:
> Can any one explain why when I run:
>
> <?php
> print"1st month: ".date("F Y",mktime(0,0,0,1))."<br>";
> print"2nd month: ".date("F Y",mktime(0,0,0,2))."<br>";
> print"3rd month: ".date("F Y",mktime(0,0,0,3))."<br>";
> print"4th month: ".date("F Y",mktime(0,0,0,4))."<br>";
> ?>
>
> I get the following output?
>
> 1st month: January 2005
> 2nd month: March 2005
> 3rd month: March 2005
> 4th month: May 2005
>
>
>
> - think it's something to do with today's date. Can anyone confirm they get
> the same?
"Arguments may be left out in order from right to left; any arguments
thus omitted will be set to the current value according to the local
date and time." [0]
So today mktime(0,0,0,2) is equivalent to mktime(0,0,0,2,31), and
February having only 28 or 29 days, it rolls it over to next month. Same
thing with April: 2005-04-31 becomes 2005-05-01.
.k
[0] http://php.net/mktime
More information about the thelist
mailing list