PHP Tutorial - PHP cal_days_in_month() Function






Definition

The cal_days_in_month() function returns the number of days in a month for a specified year.

Syntax

PHP cal_days_in_month() Function has the following syntax.

cal_days_in_month(calendar,month,year);

Parameter

PHP cal_days_in_month() Function has the following parameters.

ParameterIs RequiredDescription
calendarRequired.Calendar to use.
monthRequired.Selected Month
yearRequired.Selected year

Example

Returns the number of days in a month for a specified year


<?php
$d=cal_days_in_month(CAL_GREGORIAN,10,2012);
echo "There was $d days in October 2012";
?>

The code above generates the following result.