PHP Function Reference

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.

PHP Calendar Functions

FunctionsDescription
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.

ConstantsTypeDescription
CAL_EASTER_DEFAULTIntegerFor easter_days(): calculate Easter for years before 1753 according to the Julian calendar, and for later years according to the Gregorian calendar.
CAL_EASTER_ROMANIntegerFor 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_GREGORIANIntegerForeaster_days(): calculate Easter according to the Proleptic Gregorian calendar.
CAL_EASTER_ALWAYS_JULIANIntegerFor easter_days(): calculate Easter according to the Julian calendar.
CAL_GREGORIANIntegerFor cal_days_in_month(), cal_from_jd(), cal_info() and cal_to_jd(): use the Proleptic Gregorian calendar.
CAL_JULIANIntegerFor cal_days_in_month(), cal_from_jd(), cal_info() and cal_to_jd(): use the Julian calendar.
CAL_JEWISHIntegerFor cal_days_in_month(), cal_from_jd(), cal_info() and cal_to_jd(): use the Jewish calendar.
CAL_FRENCHIntegerFor cal_days_in_month(), cal_from_jd(), cal_info() and cal_to_jd(): use the French Republican calendar.
CAL_NUM_CALSIntegerThe number of available calendars.
CAL_JEWISH_ADD_ALAFIM_GERESHIntegerFor jdtojewish(): adds a geresh symbol (which resembles a single-quote mark) as thousands separator to the year number.
CAL_JEWISH_ADD_ALAFIMIntegerFor jdtojewish(): adds the word alafim as thousands separator to the year number.
CAL_JEWISH_ADD_GERESHAYIMIntegerFor jdtojewish(): add a gershayim symbol (which resembles a double-quote mark) before the final letter of the day and year numbers.
CAL_DOW_DAYNOIntegerFor jddayofweek(): the day of the week as int, where 0 means Sunday and 6 means Saturday.
CAL_DOW_SHORTIntegerFor jddayofweek(): the abbreviated English name of the day of the week.
CAL_DOW_LONGIntegerFor jddayofweek(): the English name of the day of the week.
CAL_MONTH_GREGORIAN_SHORTIntegerFor jdmonthname(): the abbreviated Gregorian month name.
CAL_MONTH_GREGORIAN_LONGIntegerFor jdmonthname(): the Gregorian month name.
CAL_MONTH_JULIAN_SHORTIntegerFor jdmonthname(): the abbreviated Julian month name.
CAL_MONTH_JULIAN_LONGIntegerFor jdmonthname(): the Julian month name.
CAL_MONTH_JEWISHIntegerFor jdmonthname(): the Jewish month name.
CAL_MONTH_FRENCHIntegerFor jdmonthname(): the French Republican month name.

5