The cal_days_in_month() function returns the number of days in a specific month of a year. This is the predefined function of PHP.
cal_days_in_month() function syntax
cal_days_in_month(calendar_name,month,year);
Example : -
<?php
$days = cal_days_in_month(CAL_GREGORIAN,2,2020);
echo $days;
?>
Know all the number of days in any year
<?php
$days = 0;
for($i=1;$i<=12;$i++)
{
$days += cal_days_in_month(CAL_GREGORIAN,$i,2020);
}
echo $days;
?>
Publish A Comment