PHP cal_days_in_month() Function
The PHP cal_days_in_month() function returns the number of days in the month of year for the specified calendar.
Syntax
cal_days_in_month(calendar, month, year)
Parameters
calendar |
Required. Specify the calendar to use for calculation. |
month |
Required. Specify the month in the selected calendar. |
year |
Required. Specify the year in the selected calendar. |
Return Value
Returns the length in days of the selected month in the given calendar.
Exceptions
NA.
Example:
The example below shows the usage of cal_days_in_month() function.
<?php $days = cal_days_in_month(CAL_GREGORIAN, 8, 2015); echo "There were $days days in August 2015. \n"; $days = cal_days_in_month(CAL_JULIAN, 2, 2015); echo "There were $days days in February 2015. \n"; $days = cal_days_in_month(CAL_JEWISH, 2, 2016); echo "There were $days days in February 2016. \n"; ?>
The output of the above code will be:
There were 31 days in August 2015. There were 28 days in February 2015. There were 29 days in February 2016.
❮ PHP Calendar Reference