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 | red() function
- D3.js | d3.map.set() Function
- p5.js | sin() function
- PHP | pow( ) Function
- p5.js | cos() function
- p5.js | log() function
- D3.js | d3.set.has() Function
- p5.js | max() function
- p5.js | arc() Function
- PHP | pi( ) Function
- CSS | var() Function
- PHP | Ds\Map xor() 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 email@example.com. 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.