morganestes
8/7/2013 - 10:25 PM

Cheaters to build forms with dates.

Cheaters to build forms with dates.

<select id="exp-month" name="exp-month" class="span2">
  <option>Month</option>
  <?php
  $months = array(
  	1  => 'Jan',
  	2  => 'Feb',
  	3  => 'Mar',
  	4  => 'Apr',
  	5  => 'May',
  	6  => 'June',
  	7  => 'July',
  	8  => 'Aug',
  	9  => 'Sept',
  	10 => 'Oct',
  	11 => 'Nov',
  	12 => 'Dec',
  );
    
  for ($month = 1; $month <= 12; $month ++) {
    $month_name = $months[$month];
    $month      = sprintf("%02s", $month);
   
    echo "<option value='$month'>$month &mdash; $month_name</option>\n";
	}
?>
</select>
<select id="exp-year" name="exp-year" class="span1">
  <option>Year</option>
<?php
$this_year = date('Y');

for( $year = $this_year; $year <= $this_year + 12; $year++ )
	echo "<option value='$year'>$year</option>";
?>
</select>