PHP Calendar
The calendar extension presents a series of functions to simplify converting between different calendar formats.
Example to print the number of days in a month for a given year and calendar
<?php
$number = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31
echo "There were {$number} days in August 2003";
?>
Output
There were 31 days in August 2003
Example to return information about a particular calendar
<?php
$info = cal_info(0);
print_r($info);
?>
Output
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
)
Calendar Definition
The calendar extension presents a series of functions to simplify converting between different calendar formats.
The intermediary or standard it is based on is the Julian Day Count.
The Julian Day Count is a count of days starting from January 1st, 4713 B.C. To convert between calendar systems, you must first convert to Julian Day Count, then to the calendar system of your choice.
Julian Day Count is very different from the Julian Calendar!
For more information on a calendar, systems visit http://www.hermetic.ch/cal_stud/jdn.htm
Visit Also http://www.fourmilab.ch/documents/calendar/
Requirements
No external libraries are needed to build this extension.
Installation
To get these functions to work, you have to compile PHP with --enable-calendar.
The Windows version of PHP has built-in support for this extension. You do not need to load any additional extensions in order to use these functions.
Run-time Configuration
This extension has no configuration directives defined in php.ini.
Resource Types
This extension has no resource types defined.
Predefined Constants
This calendar extension provided the in-built predefined constants.
- CAL_EASTER_DEFAULT - (integer) For easter_days(): calculate Easter for years before 1753 according to the Julian calendar, and for later years according to the Gregorian calendar.
- CAL_EASTER_ROMAN - (integer) For easter_days(): calculate Easter for years before 1583 according to the Julian calendar, and for later years according to the Gregorian calendar.
- CAL_EASTER_ALWAYS_GREGORIAN - (integer) For easter_days(): calculate Easter according to the proleptic Gregorian calendar.
- CAL_EASTER_ALWAYS_JULIAN - (integer) For easter_days(): calculate Easter according to the Julian calendar.
- CAL_GREGORIAN - (integer) For cal_days_in_month(), cal_from_jd(), cal_info() and cal_to_jd(): use the proleptic Gregorian calendar.
- CAL_JULIAN - (integer) For cal_days_in_month(), cal_from_jd(), cal_info() and cal_to_jd(): use the Julian calendar.
- CAL_JEWISH - (integer) For cal_days_in_month(), cal_from_jd(), cal_info() and cal_to_jd(): use the Jewish calendar.
- CAL_FRENCH - (integer) For cal_days_in_month(), cal_from_jd(), cal_info() and cal_to_jd(): use the French Repuclican calendar.
- CAL_NUM_CALS - (integer) The number of available calendars.
- CAL_JEWISH_ADD_ALAFIM_GERESH - (integer) For jdtojewish(): adds a geresh symbol (which resembles a single-quote mark) as thousands separator to the year number.
- CAL_JEWISH_ADD_ALAFIM - (integer) For jdtojewish(): adds the word alafim as thousands separator to the year number.
- CAL_JEWISH_ADD_GERESHAYIM - (integer) For jdtojewish(): add a gershayim symbol (which resembles a double-quote mark) before the final letter of the day and year numbers.
- CAL_DOW_DAYNO - (integer) For jddayofweek(): the day of the week as integer, where 0 means Sunday and 6 means Saturday.
- CAL_DOW_SHORT - (integer) For jddayofweek(): the abbreviated English name of the day of the week.
- CAL_DOW_LONG - (integer) For jddayofweek(): the English name of the day of the week.
- CAL_MONTH_GREGORIAN_SHORT - (integer) For jdmonthname(): the abbreviated Gregorian month name.
- CAL_MONTH_GREGORIAN_LONG - (integer) For jdmonthname(): the Gregorian month name.
- CAL_MONTH_JULIAN_SHORT - (integer) For jdmonthname(): the abbreviated Julian month name.
- CAL_MONTH_JULIAN_LONG - (integer) For jdmonthname(): the Julian month name.
- CAL_MONTH_JEWISH - (integer) For jdmonthname(): the Jewish month name.
- CAL_MONTH_FRENCH - (integer) For jdmonthname(): the French Republican month name.
Calendar Functions
- cal_days_in_month — Return the number of days in a month for a given year and calendar
- cal_from_jd — Converts from Julian Day Count to a supported calendar
- cal_info — Returns information about a particular calendar
- cal_to_jd — Converts from a supported calendar to Julian Day Count
- easter_date — Get Unix timestamp for midnight on Easter of a given year
- easter_days — Get the number of days after March 21 on which Easter falls for a given year
- frenchtojd — Converts a date from the French Republican Calendar to a Julian Day Count
- gregoriantojd — Converts a Gregorian date to Julian Day Count
- jddayofweek — Returns the day of the week
- jdmonthname — Returns a monthly name
- jdtofrench — Converts a Julian Day Count to the French Republican Calendar
- jdtogregorian — Converts Julian Day Count to Gregorian date
- jdtojewish — Converts a Julian day count to a Jewish calendar date
- jdtojulian — Converts a Julian Day Count to a Julian Calendar Date
- jdtounix — Convert Julian Day to Unix timestamp
- jewishtojd — Converts a date in the Jewish Calendar to Julian Day Count
- juliantojd — Converts a Julian Calendar date to Julian Day Count
- unixtojd — Convert Unix timestamp to Julian Day