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()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。