PHP - Calendar
The calendar extension contains a number 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
For these functions to work, you have to compile PHP with --enable-calendar.
The Windows version of PHP has built-in support for this extension.
Runtime Configuration
This extension has no configuration directives defined in php.ini.
PHP Calendar Functions
Functions | Description |
---|---|
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 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 month 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. |
PHP Calendar Predefined Constants
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
Constants | Type | Description |
---|---|---|
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 | Foreaster_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 Republican 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 int, 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. |