Forum Moderators: coopster

Message Too Old, No Replies

Problem with the mktime function

         

benj0323

7:27 am on Jul 31, 2004 (gmt 0)

10+ Year Member



This is really strange but the mktime() function is acting really weird for me. I'll just write the code and then next to it write what it displays.

Here is the original code
$option_disp = date('F',mktime(0,0,0,$i));
Where $i increases by 1 from 1 - 12.

Here is the output I get.

$option_disp = date('F',mktime(0,0,0,1));
This outputs January.

$option_disp = date('F',mktime(0,0,0,2));
This outputs March.

Where did February go?
Is there a better way to do this?

Any help is greatly appreciated. Thank you.

vincevincevince

9:23 am on Jul 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$option_disp = date('F',mktime(0, 0, 0, $i, 0, 0));

RonPK

9:26 am on Jul 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you leave out the day and year, the current values will be used. Today that would be mktime(0,0,0,2,31,2004), which doesn't make sense.

Try date('F',mktime(0,0,0,$i,1)) as all months have a first day.