Get the number of days in a month in PHP

Source: Internet
Author: User

<?PHP$days=Cal_days_in_month(Cal_gregorian, 4, 2011); Echo"Returns the number of days in 2011-4."$days." <br/> "; $days=Date(' t ',Strtotime("2011-4-1")); Echo"Returns the number of days in 2011-4."$days." <br/> "; $days=Date("T"); Echo"Number of days in the current month".$days." <br/> ";?>

Cal_days_in_month: Returns the number of days of a month in a calendar year

Parameter description:

Cal_days_in_month ($par 1, $par 2, $par 3);

$par 1: A calendar for calculation, PHP calendar constant

$par 2: Parameter $PAR1 Select a month in the calendar

$par 3: Select a year in the calendar

return value:

$par 1 days of the month of the selected calendar

  

PHP Calendar constants: The calendar extension contains functions that simplify conversion between different calendar formats.

In order for these functions to work, you must compile PHP through--enable-calendar. window, the support for calendar extensions has been integrated

The constants in the case are Cal_gregorian, which are predefined constants of PHP, like constants such as Php_os

Gregorian means: Gregorian calendar; Solar Calendar

Get the number of days in a month in PHP

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.