PHP 日历函数

PHP cal_days_in_month() 函数返回指定日历年份月份中的天数

语法

cal_days_in_month(calendar, month, year) 

参数

calendar必填。 指定用于计算的日历。
month必填。 指定所选日历中的月份。
year必填。 指定所选日历中的年份。

返回值

返回所选月份的长度(以天为单位)给定的日历。

例外

无。

示例:

下面的示例显示了 cal_days_in_month() 的用法 函数。

<?php
$days = cal_days_in_month(CAL_GREGORIAN, 8, 2015); 
echo "There were $days days in August 2015. \n";

$days = cal_days_in_month(CAL_JULIAN, 2, 2015); 
echo "There were $days days in February 2015. \n";

$days = cal_days_in_month(CAL_JEWISH, 2, 2016); 
echo "There were $days days in February 2016. \n";
?> 

上述代码的输出将是:

There were 31 days in August 2015. 
There were 28 days in February 2015. 
There were 29 days in February 2016.