Php generates a drop-down list of years, quarters, and months from the specified time

Source: Internet
Author: User

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 ')

*/


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.