[thelist] wierd results from mktime

Jay Blanchard jay.blanchard at niicommunications.com
Thu Mar 31 08:27:49 CST 2005

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

from http://www.php.net/mktime

"Warning: Note the strange order of arguments, which differs from the
order of arguments in a regular Unix mktime() call and which does not
lend itself well to leaving out parameters from right to left (see
below). It is a common error to mix these values up in a script."

You are leaving out day and year past the month.

More information about the thelist mailing list