Does php Date mktime() Function show different value on End of the month? -


to list months in dropdown used php function

<select name="month" class="span3">         <?php             for($m = 1;$m <= 12; $m++){                  $month =  date("f", mktime(0, 0, 0, $m));?>                 <option  value="<?php echo $m; ?>"><?php echo $month; ?></option>          <?php } ?>     </select> 

it working fine when check today (i.e 31-07-2013) showing month

    <select class="span3" name="month">        <option value="1">january</option>        <option value="2">march</option>        <option value="3">march</option>        <option value="4">may</option>        <option value="5">may</option>        <option value="6">july</option>        <option value="7">july</option>        <option value="8">august</option>        <option value="9">october</option>        <option value="10">october</option>        <option value="11">december</option>        <option value="12">december</option>     </select> 

when check date format ('y-m-d') showing first , last date of month , doesn't show february feb showing 2013-03-03. when modify mktime function mktime(0, 0, 0, $m,1,2013) results coming expected. there need when use mktime() or date() function in php.

add 5th parameter fix this.

$month =  date("f", mktime(0, 0, 0, $m, 1)); 

it's 31st, , months above have 31 days.

to clarify happens, default value 5th parameter current day. pass number higher number of days in month, rolls on next month.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -