mktime and date questions..
Posted
by mjboggess
on Stack Overflow
See other posts from Stack Overflow
or by mjboggess
Published on 2010-05-07T19:57:12Z
Indexed on
2010/05/07
19:58 UTC
Read the original article
Hit count: 124
php
Hello SO! I am working on a small project and am playing with date() and mktime() in PHP. Compare the two code blocks and their output, notice the second sample adds one to the month in it's first mktime.
$monthis = 5;
echo date('F', mktime(0,0,0,$monthis,0,0)) . " 1, 2010 is on a " . date("l F", mktime(0, 0, 0, $monthis, 1, 2010));
puts out
April 1, 2010 is on a Saturday May
but if I change it to
$monthis = 5;
echo date('F', mktime(0,0,0,$monthis + 1,0,0)) . " 1, 2010 is on a " . date("l F", mktime(0, 0, 0, $monthis, 1, 2010));
puts out
May 1, 2010 is on a Saturday May
Why do I have to add one to the month in the first mktime so that both emit the same month?
Any help or clarity would be appreciated. Thanks :)
© Stack Overflow or respective owner