PHP cal_info() Function
The PHP cal_info() function returns information on the specified calendar. The names of the different calendars which can be used as calendar are as follows:
- 0 or CAL_GREGORIAN - Gregorian Calendar
- 1 or CAL_JULIAN - Julian Calendar
- 2 or CAL_JEWISH - Jewish Calendar
- 3 or CAL_FRENCH - French Revolutionary Calendar
If no calendar is specified, this function returns information on all supported calendars as an array.
Syntax
cal_info(calendar)
Parameters
calendar |
Optional. Specify the calendar to return information for. If no calendar is specified information on all calendars is returned. |
Return Value
Returns an array containing calendar information which are listed below:
- month
- abbrevmonth
- maxdaysinmonth
- calname
- calsymbol
Exceptions
NA.
Example:
The example below shows the usage of cal_info() function.
<?php //displaying information about //Gregorian calendar print_r(cal_info(0)); ?>
The output of the above code will be:
Array ( [months] => Array ( [1] => January [2] => February [3] => March [4] => April [5] => May [6] => June [7] => July [8] => August [9] => September [10] => October [11] => November [12] => December ) [abbrevmonths] => Array ( [1] => Jan [2] => Feb [3] => Mar [4] => Apr [5] => May [6] => Jun [7] => Jul [8] => Aug [9] => Sep [10] => Oct [11] => Nov [12] => Dec ) [maxdaysinmonth] => 31 [calname] => Gregorian [calsymbol] => CAL_GREGORIAN )
Example:
Consider one more example where information about Jewish calendar is fetched.
<?php //displaying information about //Jewish calendar print_r(cal_info(CAL_JEWISH)); ?>
The output of the above code will be:
Array ( [months] => Array ( [1] => Tishri [2] => Heshvan [3] => Kislev [4] => Tevet [5] => Shevat [6] => Adar I [7] => Adar II [8] => Nisan [9] => Iyyar [10] => Sivan [11] => Tammuz [12] => Av [13] => Elul ) [abbrevmonths] => Array ( [1] => Tishri [2] => Heshvan [3] => Kislev [4] => Tevet [5] => Shevat [6] => Adar I [7] => Adar II [8] => Nisan [9] => Iyyar [10] => Sivan [11] => Tammuz [12] => Av [13] => Elul ) [maxdaysinmonth] => 30 [calname] => Jewish [calsymbol] => CAL_JEWISH )
❮ PHP Calendar Reference