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 ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
- PHP | opendir() Function
- PHP | cal_to_jd() Function
- PHP | stream_get_transports() Function
- PHP | Ds\Deque pop() Function
- PHP | SimpleXMLElement children() Function
- PHP | array_intersect_ukey() Function
- PHP | is_numeric() 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.