PHP determines the number of days in the current month

Source: Internet
Author: User
Tags php and mysql

Determine the number of days in the current month

To determine the number of days in the current month, you can use the T parameter of date () to consider the following code:

printf ("There is%d days in%s.", Date ("T"), Date ("F"));

If executed in April, the following results are output:

There is in April.


Determine the number of days in any given month

Sometimes you might want to determine the number of days in a month, not the current month. This requirement cannot be achieved with the date () function, because

It requires a timestamp, and now only the year and the month. However, the mktime () function can be used to generate the desired result. Suppose the Greek

To determine the number of days in February 2007:

$lastday = Mktime (o, 0, 0, 3, 0,);p rintf ("There is%d days in February.", Date ("T$lastday");

Execute this code to get the following output:

There is in February 2007.

"Read" The detailed tutorial see "PHP and MySQL program design," The 52nd page, OK Bookstore (www.okpdf.com) to provide e-book: Click to download

650) this.width=650; "src=" Http://www.okpdf.com/attachment/1407/thread/3_1_f0f2fd7ffe57c75.png "width=" 384 "height = "516" alt= "3_1_f0f2fd7ffe57c75.png"/>



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.