cal_info(): Information about calendar used

Inspect supported calendar information

cal_info() returns names, month data and related information for a selected calendar.

$info = cal_info(CAL_GREGORIAN);
echo $info['calname'];
This function returns all information available on particular calendar type. Here is the syntax
cal_info($calendar);
Here cal_int is an integer to identify the type of calendar required. Here are the values

	0 : CAL_GREGORIAN ( Gregorian Calendar )
1 : CAL_JULIAN ( Julian Calendar )
2 : CAL_JEWISH ( Jewish Calendar )
3 : CAL_FRENCH ( French Revolutionary Calendar )
Here is an example of displaying information about the Julian calendar. Use the named constant instead of the numeric calendar ID.
$a = cal_info(CAL_JULIAN);
foreach($a as $key => $val) {
echo "$key -> $val <br>"; 
	foreach($val as $key1 => $val1) {
		echo "$key1 -> $val1 <br>"; 
	}
}
The Output is here
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 -> Julian 
calsymbol -> CAL_JULIAN 

Inspect every supported calendar

Calling cal_info() without a calendar argument returns information for all supported calendars. Use nested foreach loops; the old each() function was removed from PHP.

$calendars = cal_info();
foreach ($calendars as $calendarId => $calendar) {
    echo $calendar['calname'] . "<br>";
    foreach ($calendar['months'] as $number => $month) {
        echo $number . ' - ' . $month . "<br>";
    }
}
DEMO of cal_info() is displayed
Calendar Functions


Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer