3.16. Using Non-Gregorian Calendars
PHP's calendar extension provides conversion functions for working with the Julian calendar, as well as the French Republican and Jewish calendars. To use these functions, the calendar extension must be loaded.
These functions use the Julian day count (which is different than the Julian calendar) as their intermediate format to move information between them.
$jd = gregoriantojd(3,9,1876); // March 9, 1876; $jd = 2406323 $gregorian = jdtogregorian($jd); // $gregorian = 3/9/1876
The valid range for the Gregorian calendar is 4714 BCE to 9999 CE.
// February 29, 1900 (not a Gregorian leap year) $jd = juliantojd(2,29,1900); // $jd = 2415092 $julian = jdtojulian($jd); // $julian = 2/29/1900 $gregorian = jdtogregorian($jd); // $gregorian = 3/13/1900
The valid range for the Julian calendar is 4713 BCE to 9999 CE, but since it was created in 46 BCE, you run the risk of annoying Julian calendar purists if you use it for dates before that.
$jd = frenchtojd(8,13,11); // 13 floréal XI; $jd = 2379714 $french = jdtofrench($jd); // $french = 8/13/11 $gregorian = jdtofregorian($jd); // $gregorian = 5/3/1803; sale of Louisiana to U.S.
The valid range for the French Republican calendar is September 1792 to September 1806, which is small, but since the calendar was only in use from October 1793 to January 1806, it's comprehensive enough.
$jd = JewishToJD(6,14,5761); // Adar 14, 5761; $jd = 2451978 $jewish = JDToJewish($jd); // $jewish = 6/14/5761 $gregorian = JDToGregorian($jd); // $gregorian = 3/9/2001
The valid range for the Jewish calendar starts with 3761 BCE (year 1 on the Jewish calendar).
3.16.4. See Also
Documentation for the calendar functions at http://www.php.net/calendar; the history of the Gregorian calendar is explained at http://scienceworld.wolfram.com/astronomy/GregorianCalendar.html.
Copyright © 2003 O'Reilly & Associates. All rights reserved.