Open In App

PHP | cal_days_in_month()

cal_days_in_month() is an inbuilt function which returns the number of days in a particular month of a specified calendar. We have to pass calendar type, month and year as the parameter and the function will return the number of days in that month of the specified year of the calendar.
Syntax  

int cal_days_in_month ( int $calendar, int $month, int $year )

Parameters :  



Below is  the list of possible values that ‘calendar’ parameter can hold : 

Return Value : Returns the number of days in the month of the year for the specified calendar. 






<!DOCTYPE html>
<html>
<body>
 
<?php
$d = cal_days_in_month(CAL_GREGORIAN, 2, 1965); // Calendar Type - Gregorian
echo "There was $d days in February 1965.<br>";
 
$d = cal_days_in_month(CAL_GREGORIAN, 2, 2004); // Calendar Type - Gregorian
echo "There was $d days in February 2004.";
?>
</body>
</html>

Output : 

There was 28 days in February 1965.
There was 29 days in February 2004.
Article Tags :