📜  PHP | cal_days_in_month()

📅  最后修改于: 2022-05-13 01:56:29.235000             🧑  作者: Mango

PHP | cal_days_in_month()

cal_days_in_month() 是一个内置函数,它返回指定日历的特定月份的天数。我们必须传递日历类型、月份和年份作为参数,该函数将返回指定日历年的该月的天数。
句法

int cal_days_in_month ( int $calendar, int $month, int $year )

参数 :

  • Calendar :用于计算的日历类型。该值是必需的。
  • 月:所选日历中的月份。该值是必需的。
  • Year :所选日历中的年份。该值也是必需的。

以下是“日历”参数可以包含的可能值列表:

  • 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

返回值:返回指定日历在一年中的月份中的天数。

php



 
";
 
$d = cal_days_in_month(CAL_GREGORIAN, 2, 2004); // Calendar Type - Gregorian
echo "There was $d days in February 2004.";
?>



输出 :

There was 28 days in February 1965.
There was 29 days in February 2004.