cal_days_in_month()是一个内置函数,它返回指定日历的特定月份中的天数。我们必须传递日历类型,月份和年份作为参数,该函数将返回指定年份的日历月份中的天数。
句法
int cal_days_in_month ( int $calendar, int $month, int $year )
参数:
- Calender:用于计算的日历类型。此值是必需的。
- Month :所选日历中的月份。此值是必需的。
- Year :所选日历中的年份。该值也是必需的。
以下是“ calendar”参数可以保存的可能值的列表:
- CAL_GREGORIAN
- CAL_JULIAN
- CAL_JEWISH
- CAL_FRENCH
- CAL_NUM_CALS
- CAL_DOW_DAYNO
- CAL_DOW_SHORT
- CAL_DOW_LONG
- CAL_MONTH_GREGORIAN_SHORT
- CAL_MONTH_GREGORIAN_LONG
- CAL_MONTH_JULIAN_SHORT
- CAL_MONTH_JULIAN_LONG
- CAL_MONTH_JEWISH
- CAL_MONTH_FRENCH
- CAL_EASTER_DEFAULT
- CAL_EASTER_ROMAN
- CAL_EASTER_ALWAYS_GREGORIAN
- CAL_EASTER_ALWAYS_JULIAN
- CAL_JEWISH_ADD_ALAFIM_GERESH
- CAL_JEWISH_ADD_ALAFIM
- CAL_JEWISH_ADD_GERESHAYIM
返回值:返回指定日历在一年中的月份中的天数。
<!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>
输出:
There was 28 days in February 1965. There was 29 days in February 2004.
相关用法
注:本文由纯净天空筛选整理自Saptarshi_Das大神的英文原创作品 PHP | cal_days_in_month()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。