[thelist] wierd results from mktime

Mark Groen markgroen at gmail.com
Thu Mar 31 08:37:20 CST 2005


----- Original Message ----- 
From: "David Felton" <>
To: <thelist at lists.evolt.org>
Sent: March 31, 2005 6:00 AM
Subject: [thelist] wierd results from mktime


> 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

You are missing an argument, this works:
<?php
print"1st month: ".date("F Y",mktime(0,0,0,1,0))."<br>";
print"2nd month: ".date("F Y",mktime(0,0,0,2,0))."<br>";
print"3rd month: ".date("F Y",mktime(0,0,0,3,0))."<br>";
print"4th month: ".date("F Y",mktime(0,0,0,4,0))."<br>";
?>
mind, this outputs December as the first month because of the zero:
If the month is greater than 12, it goes into the next year. If it is
less than 1, it goes into the previous year.

http://ca3.php.net/manual/en/function.mktime.php

hth!

cheers,

               Mark

MG Web Services
Web Site Hosting and Development
www.mgwebservices.ca
mark at mgwebservices.ca
604-780-6917
Bowen Island, B.C., Canada





More information about the thelist mailing list