PHP - Calendar Functions
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.
Installation
To get these functions to work, you have to compile PHP with --enable-calendar.
Runtime Configuration
This extension has no configuration directives defined in php.ini.
This extension is supported directly by the Windows version of PHP. You do not need to load any additional extensions to use these features.
Requirements
PHP Calendar Constants
The constants listed below are defined by this extension and will only be available once it has been compiled into PHP or dynamically loaded at runtime.
| Sr.No | Constant & Description |
|---|---|
| 1 |
CAL_GREGORIAN Gregorian calendar |
| 2 |
CAL_JULIAN Julian calendar |
| 3 |
CAL_JEWISH Jewish calendar |
| 4 |
CAL_FRENCH French Republican calendar |
| 5 |
CAL_EASTER_DEFAULT Calculate Easter using Julian calendar before 1753 and Gregorian calendar after |
| 6 |
CAL_EASTER_ROMAN Calculate Easter using Julian calendar before 1583 and Gregorian calendar after |
| 7 |
CAL_EASTER_ALWAYS_GREGORIAN Calculate Easter using Gregorian calendar |
| 8 |
CAL_EASTER_ALWAYS_JULIAN Calculate Easter using Julian calendar |
| 9 |
CAL_NUM_CALS The number of available calendars |
| 10 |
CAL_JEWISH_ADD_ALAFIM_GERESH Adds a geresh symbol as a thousands separator in the year number |
| 11 |
CAL_JEWISH_ADD_ALAFIM Adds the word "alafim" as a thousands separator in the year number |
| 12 |
CAL_JEWISH_ADD_GERESHAYIM Adds a gershayim symbol before the final letter of the day and year numbers |
| 13 |
CAL_DOW_DAYNO The day of the week as an integer, where 0 means Sunday and 6 means Saturday |
| 14 |
CAL_DOW_SHORT The abbreviated English name of the day of the week |
| 15 |
CAL_DOW_LONG The full English name of the day of the week |
| 16 |
CAL_MONTH_GREGORIAN_SHORT The abbreviated Gregorian month name |
| 17 |
CAL_MONTH_GREGORIAN_LONG The full Gregorian month name |
| 18 |
CAL_MONTH_JULIAN_SHORT The abbreviated Julian month name |
| 19 |
CAL_MONTH_JULIAN_LONG The full Julian month name |
| 20 |
CAL_MONTH_JEWISH The Jewish month name |
| 21 |
CAL_MONTH_FRENCH The French Republican month name |
List of Functions
PHP − indicates the earliest version of PHP that supports the function.
| Sr.No | Function & Description | PHP |
|---|---|---|
| 1 | cal_days_in_month()
Returns the number of days in a month for a specified year and calendar |
4 |
| 2 | cal_from_jd()
Converts a Julian day count into a date of a specified calendar |
4 |
| 3 | cal_info()
Returns information about a given calendar |
4 |
| 4 | cal_to_jd()
Converts a date to Julian day count |
4 |
| 5 | easter_date()
Returns the Unix timestamp for midnight on Easter of a specified year |
4 |
| 6 | easter_days()
Returns the number of days after March 21, on which Easter falls for a specified year |
4 |
| 7 | FrenchToJD()
Converts a French Republican date to a Julian day count |
4 |
| 8 | GregorianToJD()
Converts a Gregorian date to a Julian day count |
4 |
| 9 | JDDayOfWeek()
Returns the day of a week |
4 |
| 10 | JDMonthName()
Returns a month name |
4 |
| 11 | JDToFrench()
Converts a Julian day count to a French Republican date |
4 |
| 12 | JDToGregorian()
Converts a Julian day count to a Gregorian date |
4 |
| 13 | JDToJewish()
Converts a Julian day count to a Jewish date |
4 |
| 14 | JDToJulian()
Converts a Julian day count to a Julian date |
4 |
| 15 | JDToUnix()
Converts a Julian day count to a Unix timestamp |
4 |
| 16 | JewishToJD()
Converts a Jewish date to a Julian day count |
4 |
| 17 | JulianToJD()
Converts a Julian date to a Julian day count |
4 |
| 18 | UnixToJD()
Converts a Unix timestamp to a Julian day count |
4 |