PHP Calendar Functions

PHP Calendar Introduction

The calendar extension includes functions to simplify the conversion between different calendar formats.

It is based on Julian Day Count (Julian Day Number) and starts counting from January 1, 4713 BC.

Notes:To convert between calendar formats, you must first convert to Julian Day Count, and then convert to the calendar format you choose.

Notes:Julian Day Count (Julian Day Number) and Julian Calendar are not the same thing!

Installation

In order for these functions to work, you must compile PHP with --enable-calendar.

PHP's Windows version has built-in support for the calendar extension, so the Calendar functions will work automatically.

PHP 5 Calendar functions

Function Description
cal_days_in_month() Return the number of days in a month for the specified year and calendar.
cal_from_jd() Convert Julian day count to the date of the specified calendar.
cal_info() Return information about the specified calendar.
cal_to_jd() Convert the date of the specified calendar to Julian day count.
easter_date() Return the Unix timestamp for Easter midnight of the specified year.
easter_days() Return the number of days between Easter and March 21 for the specified year.
frenchtojd() Convert French Republican calendar date to Julian day count.
gregoriantojd() Convert Gregorian calendar date to Julian day count.
jddayofweek() Return the day of the week for the date.
jdmonthname() Return the name of the month.
jdtofrench() Convert Julian day count to French Republican calendar date.
jdtogregorian() Convert Gregorian calendar to Julian day count.
jdtojewish() Convert Julian day count to Jewish calendar date.
jdtojulian() Convert Julian day count to Julian calendar date.
jdtounix() Convert Julian day count to Unix timestamp.
jewishtojd() Convert Jewish calendar date to Julian day count.
juliantojd() Convert Julian calendar date to Julian day count.
unixtojd() Convert Unix timestamp to Julian day count.

PHP 5 predefined Calendar constants

Constants Type PHP version
CAL_GREGORIAN Integer PHP 4
CAL_JULIAN Integer PHP 4
CAL_JEWISH Integer PHP 4
CAL_FRENCH Integer PHP 4
CAL_NUM_CALS Integer PHP 4
CAL_DOW_DAYNO Integer PHP 4
CAL_DOW_SHORT Integer PHP 4
CAL_DOW_LONG Integer PHP 4
CAL_MONTH_GREGORIAN_SHORT Integer PHP 4
CAL_MONTH_GREGORIAN_LONG Integer PHP 4
CAL_MONTH_JULIAN_SHORT Integer PHP 4
CAL_MONTH_JULIAN_LONG Integer PHP 4
CAL_MONTH_JEWISH Integer PHP 4
CAL_MONTH_FRENCH Integer PHP 4
CAL_EASTER_DEFAULT Integer PHP 4.3
CAL_EASTER_ROMAN Integer PHP 4.3
CAL_EASTER_ALWAYS_GREGORIAN Integer PHP 4.3
CAL_EASTER_ALWAYS_JULIAN Integer PHP 4.3
CAL_JEWISH_ADD_ALAFIM_GERESH Integer PHP 5.0
CAL_JEWISH_ADD_ALAFIM Integer PHP 5.0
CAL_JEWISH_ADD_GERESHAYIM Integer PHP 5.0