w3resource
PHP Tutorial

PHP: cal_days_in_month() function

Description

The cal_days_in_month() function is used to get the number of days of a month for a given year and calendar.

Version:

(PHP 4 and above)

Syntax:

cal_days_in_month (calendar, month, year )

Parameters:

Name Description Required /
Optional
Type
calendar Calendar to use for calculation. Required Integer
month Month in the selected calendar. Required Integer
year Year in the selected calendar. Required Integer

Return value:

The length in days of the selected month in the specified calendar.

Value Type: Integer.

Example:

<?php
$day_count=cal_days_in_month(CAL_GREGORIAN,02,2020);
echo  ' No of days in February 2020 : ' .$day_count;
?>

Sample Output:

No. of days in February 2020 : 29 

View the example in the browser

See also

PHP Function Reference