Php tutorials generate a drop-down list of years, quarters, and months from the specified time
Function countSeason ($ start, $ end ){
$ Temp = date ("Y-m", strtotime ("$ start + 3 month "));
While ($ temp <= $ end ){
$ Time [] = $ temp;
$ Temp = date ("Y-m", strtotime ("$ temp + 3 month "));
}
Return $ time;
}
$ Time = countSeason ("2008-10", date ("Y-m "));
?>
<Select name = "select_season" id = "select">
<Option> View by quarter </option>
<? Php foreach ($ time as $ val) {?>
<Option value = "http: // www./<? Php echo $ val;?> "> <? Php echo substr ($ val, 0, 4);?> Year <? Php
$ Temp = intval (substr ($ val, 5, 2 ));
If (0 <$ temp & $ temp <4)
{Echo "1 ";}
Elseif (3 <$ temp & $ temp <7)
{Echo "2 ";}
Elseif (6 <$ temp & $ temp <10)
{Echo "3 ";}
Else
{Echo "4 ";}
?> Quarter </option>
<? Php }?>
</Select>
/*
Direct Loop
If it is month, the cycle variable increases by 1 (month) each time)
If it is a year, 12 (months) will be added each time ),
Output both date ('Y-m') and date ('y ')
*/