cal_days_in_month — Return the number of days in a month for a given year and calendar
Description
cal_days_in_month ( int
The length in days of the selected month in the given calendar$calendar
, int $month
, int $year
) : intMore details
example
$m1=date('Y-m-d',strtotime($date_of_join));
$mon_num = date("m",strtotime($m1));
$curr_year = date("Y",strtotime($m1));
$num = cal_days_in_month(CAL_GREGORIAN, $mon_num, $curr_year);
PHP code for find number of days form given month and year ?
<?php
$month = 2;
$year = 2020;
$days = $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
echo $days;
?>
month
ofyear
for the specifiedcalendar
.