Here is my PHP Code that generate a selectbox with month names + Year. I have 2 Time Stamps that I am using in the loop that start timestamp and end timestamp.
now the problem is for example if my start-timestamp represent 01.07.2011
and as in the loop I am adding only 30 Days to time stamp then i selectbox July will be displayed twice.
and if I add 31 Day then may be a month will be skiped.
Is there any function available that can add exact one month for 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 you looking for something like:
https://www.php.net/strtotime