+

PHP Cal_days_in_month () function

The cal_days_in_month() function takes three parameters: calendar, month and year and returns the number of days according to the specified month, year, and calendar.Syntax:
cal_days_in_month ($calendar, $month, $year) 
Parameters:The cal_days_in_month() function in PHP takes three parameters, as described below:
  • $calendar : Specifies the calendar you want to view, such as French, Gregorian, Hebrew, etc.
  • $month: Indicates the month in the calendar you selected.
  • $year : Indicates the year in the calendar that you selected.
  • Return value :Returns the number of days according to the specified month, year, and calendar.Errors and exceptions :
  • cal_days-in_month function produces incorrect output if the date used is earlier than 1550.
  • The cal_days-in_mon function th gives incorrect output for dates prior to leap year discovery.
  • Examples :
    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 
    The programs below illustrate the cal_days_in_month() function:Program 1 :  
    // Using the cal_days_in_month() function for
    // find out the number of days in February 1966 $days = cal_days_in_month (CAL_JEWISH, 2, 1966); echo " February 1966 had $days days. & Lt; br > " ;  
    ?>
    Output:
    February 1966 had 29 days. 
    Program 2 :  
    // Using the cal_days_in_month() function for
    // find out the number of days in February 2004 $days = cal_days_in_month (CAL_GREGORIAN, 2 , 2004); echo " February 2004 had $days days " ;  
    ?>
    Output:
    February 2004 had 29 days 
    Link:
    http://php.net/manual/en/function.cal-days-in-month.php
    Get Solution for free from DataCamp guru