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>
Comments
Post a Comment