php - Add a month in timestamp in each iteration -


here php code generate selectbox month names + year. have 2 time stamps using in loop start timestamp , end timestamp.

now problem example if start-timestamp represent 01.07.2011 , in loop adding 30 days time stamp selectbox july displayed twice. , if add 31 day may month skiped.

is there function available can add exact 1 month each iteration?

<select name="checkinmonth" class="selectform" id="checkinmonth" > <?php    for($month = $checkin_timestamp; $month <= $checkout_timestamp; $month += 30*60*60*24) {       $checkin_month = getdate($month);       $option_text =  strftime("%b %y",$month);       $option_value =  strftime("%y%m", $month);       $selected = ($checkin_selected == $option_value ? "selected='selected'" : "");           echo "<option value='{$option_value}' {$selected}>{$option_text}</option>";     } ?> </select>  

are looking like:

strtotime("+1 month", $mytimestamp);  

http://us2.php.net/strtotime


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -