サンプルコード

 

<select name="year_month">

<?php

$current_year = date('Y');

$current_month = date('m');

for ($i = 0; $i < 24; $i++) {

  $year = $current_year - floor(($current_month - 1 + $i) / 12);

  $month = ($current_month - 1 + $i) % 12 + 1;

  printf('<option value="%04d-%02d">%04d年%02d月</option>', $year, $month, $year, $month);

}

?>

</select>