Skip to content

Instantly share code, notes, and snippets.

@matthojo
Last active August 29, 2015 14:04
Show Gist options
  • Save matthojo/08d4426728271e628bc8 to your computer and use it in GitHub Desktop.
Save matthojo/08d4426728271e628bc8 to your computer and use it in GitHub Desktop.
Show months in order from current month.
<select class="ec-simple-select selectized js-month-select" name="select-month" placeholder="Select an month" tabindex="-1" style="display: none;">
<?php
for ($i=5; $i >= 1; $i--) {
echo '<option value="'.base_url().'events/bookings/'.((($current_month-$i) <= 0) ? ($current_year-1) : $current_year ).'/'.((($current_month-$i) <= 0) ? (12 + ($current_month-$i)) : ($current_month-$i)).'" >'.date('F', strtotime('01-'.((($current_month-$i) <= 0) ? (12 + ($current_month-$i)) : ($current_month-$i)).'-'.$current_year)).' '.((($current_month-$i) <= 0) ? ($current_year-1) : $current_year ).'</option>';
}
?>
<option value="<?php echo base_url();?>events/bookings/<?php echo $current_year;?>/<?php echo $current_month;?>" selected="selected"><?php echo date('F', strtotime('01-'.$current_month.'-'.$current_year));?> <?php echo ($this->uri->segment(3)) ? $this->uri->segment(3) : $current_year;?></option>
<?php
for ($i=1; $i <= 6; $i++) {
echo '<option value="'.base_url().'events/bookings/'.((($current_month+$i) >= 13) ? ($current_year+1) : $current_year ).'/'.((($current_month+$i) >= 13) ? (($current_month+$i) - 12) : ($current_month+$i)).'" >'.date('F', strtotime('01-'.((($current_month+$i) >= 13) ? (($current_month+$i) - 12) : ($current_month+$i)).'-'.$current_year)).' '.((($current_month+$i) >= 13) ? ($current_year+1) : $current_year ).'</option>';
}
?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment