In PHP, cal_info() returns information about a calendar, such as its name, its month names and the maximum number of days in a month.
If you pass a calendar constant like CAL_GREGORIAN, you get one array of details. If you pass nothing (or -1), you get an array that describes all four supported calendars. It is mostly used for lookups, for example to build a list of month names.
Syntax
Call cal_info() with the values you need. Start with this line.
PHP
$info = cal_info(CAL_GREGORIAN);
Call
What it does
cal_info(CAL_GREGORIAN)
Returns the details of the Gregorian calendar.
cal_info()
Returns an array that holds the details of all four calendars.
cal_info(CAL_JEWISH)['calname']
Returns the text Jewish.
The result for one calendar has the keys months, abbrevmonths, maxdaysinmonth, calname and calsymbol. The months arrays start at index 1, so $info['months'][1] is January.
Library declarations
PHP
cal_info(int $calendar = -1): array
Parameters
Parameter
Description
calendar
Optional. The calendar to describe: CAL_GREGORIAN (0), CAL_JULIAN (1), CAL_JEWISH (2) or CAL_FRENCH (3). The default is -1, which returns information about all calendars.
Return Value
Return Value
Description
array
For one calendar: an array with months, abbrevmonths, maxdaysinmonth, calname and calsymbol. For -1: an array of those arrays, indexed by the calendar number.
PHP Examples
Example 1 — Describe the Gregorian Calendar
Ask for the Gregorian calendar and read a few of the values from the returned array.