Calendar Functions

The Calendar extension in PHP 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 way earlier than any date most people would need to track (somewhere around 4000bc).  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 calendar systems visit http://genealogy.org/~scottlee/cal-overview.html.  Excerpts from this page are included in these instructions, and are in quotes

(string) JDToGregorian($julianday)
	(int) $julianday  Julian Day Count

	Converts Julian Day Count to a string containing the
	Gregorian date in the format of "month/day/year"

(int)	GregorianToJD($month,$day,$year)
	(int)$month
	(int)$day
	(int)$year

	Converts a Gregorian date to Julian Day Count

	Sample:
	$jd = GregorianToJD(10,11,1970);
	echo("$jd\n");
	$gregorian = JDToGregorian($jd);
	echo("$gregorian\n");

"Valid Range for Gregorian Calendar
4714 B.C. to 9999 A.D. 

Although this software can handle dates all the way back to 4714 B.C., such use may not be meaningful. The Gregorian calendar was not instituted until October 15, 1582 (or October 5, 1582 in the Julian calendar). Some countries did not accept it until much later. For example, Britain converted in 1752, The USSR in 1918 and Greece in 1923. Most European countries used the Julian calendar prior to the Gregorian. "


(string) JDToJulian($julianday)
	(int) $julianday  Julian Day Count

	Converts Julian Day Count to a string containing the
	Julian Calendar Date in the format of "month/day/year"

(int)	JulianToJD($month,$day,$year)
	(int)$month
	(int)$day
	(int)$year

	Converts a Julian Calendar date to Julian Day Count.

"Valid Range for Julian Calendar
4713 B.C. to 9999 A.D. 

Although this software can handle dates all the way back to 4713 B.C., such use may not be meaningful. The calendar was created in 46 B.C., but the details did not stabilize until at least 8 A.D., and perhaps as late at the 4th century. Also, the beginning of a year varied from one culture to another - not all accepted January as the first month. "


(string) JDToJewish($julianday)
	(int)$julianday  Julian Day Count

	Converts a Julian Day Count the the Jewish Calendar

(int)	JewishToJD($month,$day,$year)
	(int)$month
	(int)$day
	(int)$year

	Converts a date in the Jewish Calendar to a Julian Day Count

"Valid Range 
Although this software can handle dates all the way back to the year 1 (3761 B.C.), such use may not be meaningful. 

The Jewish calendar has been in use for several thousand years, but in the early days there was no formula to determine the start of a month. A new month was started when the new moon was first observed. "


(string) JDToFrench($julianday)
	(int)$julianday  Julian Day Count

	Converts a Julian Day Count to the French Republican Calendar

(int)	FrenchToJD($month,$day,$year)
	(int)$month
	(int)$day
	(int)$year

	Converts a date from the French Republican Calendar to a Julian 	Day Count

"Valid Range for the French Republican Calendar

These routines only convert dates in years 1 through 14 (Gregorian dates 22 September 1792 through 22 September 1806). This more than covers the period when the calendar was in use." 

(string) JDMonthName($julianday,$mode)
	(int)$julianday Julian Day Count
	(int)$mode	Mode (see below)

	Returns a string containing a month name.  $mode tells this
	function which calendar to convert the Julian Day Count to, and
	what type of month names are to be returned.

	mode = 0  Gregorian - abreviated
	mode = 1  Gregorian
	mode = 2  Julian - abreviated
	mode = 3  Julian
	mode = 4  Jewish
	mode = 5  French Republican

(string or int) JDDayOfWeek($julianday,$mode)
	(int)$julianday Julian Day Count
	(int)$mode	Mode (see below)

	Returns the day of the week.
	Can return a string or an int depending on the mode.

	mode = 0 returns the day number as an int. 
		(0=sunday, 1=monday, etc.)
	mode = 1 returns string containing the day of week 		(english-gregorian)
	mode = 2 returns a string containing the abreviated day of week
		(english-gregorian)

