The cal_days_in_month( ) function in PHP is an inbuilt function which is used to return the number of days in a month for a specific year and according to a specific calendar such as Gregorian calendar, French calendar, Jewish calendar etc.
The cal_days_in_month() function takes three parameters which are the calendar, month and year and returns the number of days according to a specified month, year and calendar.
cal_days_in_month($calendar, $month, $year)
Parameters: The cal_days_in_month() function in PHP accepts three parameters as described below:
- $calendar: It specifies the calendar you want to consider such as French, Gregorian, Jewish etc.
- $month: It specifies the month in the calendar you have opted.
- $year: It specifies the year in the calendar you have opted.
Return Value: It returns the number of days according to a specified month, year and calendar.
Errors And Exception:
- The cal_days-in_month function gives wrong output when the date used is before 1550.
- The cal_days-in_month function gives wrong output for dates which were before the discovery of leap year.
Input: cal_days_in_month(CAL_JEWISH, 2, 1966); Output: 29 Explanation: February 1966 had 29 days. Input: cal_days_in_month(CAL_GREGORIAN, 2, 2004); Output: 29 Explanation: February 2004 had 29 days
Below programs illustrate the cal_days_in_month() function:
February 1966 had 29 days.
February 2004 had 29 days
- How to get the function name inside a function in PHP ?
- p5.js | second() function
- PHP Ds\Set get() Function
- PHP | end() Function
- PHP | pow( ) Function
- PHP | tan( ) Function
- PHP | sin( ) Function
- PHP Ds\Set sum() Function
- PHP | abs() Function
- D3.js | d3.rgb() Function
- p5.js | arc() Function
- p5.js | hex() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.