Php code _ php instance for obtaining the number of days in the year of the year

Source: Internet
Author: User
How to Use php to obtain the number of days of every month in the year of the Swiss or the year of the year, the following function: The Code is as follows:


// Obtain the number of days of a month, which can be used in any month
Function getDays ($ month, $ year)
{
Switch ($ month)
{
Case 4:
Case 6:
Case 9:
Case 11:
$ Days = 30;
Break;
Case 2:
If ($ year % 4 = 0)
{
If ($ year 0 = 0)
{
$ Days = $ year @ 0 = 0? 29: 28;
}
Else
{
$ Days = 29;
}
}
Else
{
$ Days = 28;
}
Break;
Default:
$ Days = 31;
Break;
}
Return $ days;
}
**
* Obtain the day of the week based on the timestamp.
*
* @ Param int $ time_stamp
*/
Function getWeek ($ time_stamp)
{
$ Week_num = date ("w", $ time_stamp );
Switch ($ week_num)
{
Case "0 ":
$ Week = "day ";
Break;
Case '1 ':
$ Week = "1 ";
Break;
Case '2 ':
$ Week = "2 ";
Break;
Case '3 ':
$ Week = "3 ";
Break;
Case '4 ':
$ Week = "4 ";
Break;
Case '5 ':
$ Week = "5 ";
Break;
Case '6 ':
$ Week = "6 ";
Break;
}
Return $ week;
}

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.