如何计算某一年每个月的天数?
答案 0 :(得分:2)
返回给定年份和日历的一个月天数
答案 1 :(得分:0)
为此,我创建了一个函数,如下所示:
// Calculate number of days in each month for a given year.
function getDays($year){
$num_of_days = array();
$total_month = 12;
if($year == date('Y'))
$total_month = date('m');
else
$total_month = 12;
for($m=1; $m<=$total_month; $m++){
$num_of_days[$m] = cal_days_in_month(CAL_GREGORIAN, $m, $year);
}
return $num_of_days;
}
$num_of_days = getDays('2011');
print_r($num_of_days);