Post tutorial RSS PHP reference: calendar

Perhaps the full reference list of calendar functions, explained by practical/technical examples.

Posted by on - Basic Server Side Coding

For particular descriptions of funtions, please look here:

The tutorial presents technical, practical examples, i.e. a code example // the function pattern. Doubled examples show which parameters are optional and which required.


//CAL_ (CAL-, CALendar)
//_GREGORIAN the most used calendar, Gregorian calendar
//_JULIAN Julian calendar
//_JEWISH Jewish calendar
//_FRENCH French Republican calendar, 12 months, 30 days (every month has 30 days), was used for 12 years (but you can use 1-14 as the year number)

//where month, day, year parameters are, you need to remember that the order is:
//1) month, 2) day, 3) year
//first month, then day, and year at the end!
//French calendar uses 2-digit year, 1-14
//3,25,14 or 10,30,1

//the number of days in Julian calendar, to obtain it you can use these functions:
//gregorian_to_jd(MONTH, DAY, YEAR) <- the fastest way:
//gregorian_to_jd(5, 25, 2010)
//or a general function:
//cal_to_jd(calendar, month, day, year) // e.g. // cal_to_jd(CAL_FRENCH, 10, 30, 12);

//method in easter_days() function defines the calendar to use when calculating Easter days during years that other calendars were used, e.g. during years 1582-1752, to have a Gregorian date, you need to use CAL_EASTER_ROMAN
//CAL_ (CALendar)

//mode1 in jddayofweek() function: // CAL_ (CALendar)
//0 default, returns day number (0 = Sunday, 1 = Monday, ASO) // _DOW_DAYNO (Day Of Week, DAY NUMBERS)
//1 returns the value as English day name // _DOW_LONG (Day Of Week, LONG name)
//2 returns the value as abbreviated English day name // _DOW_SHORT (Day Of Week, SHORT name)

//mode2 in jdmonthname() function: // CAL_ (CALendar)
//0 abbreviated Gregorian (Jan, Feb, etc.) // _MONTH_GREGORIAN_SHORT
//1 full Gregorian (January, February, ASO) // _MONTH_GREGORIAN_LONG
//2 abbreviated Julian (Jan, Feb, etc.) // _MONTH_JULIAN_SHORT
//3 full Julian (January, February, ASO) // _MONTH_JULIAN_LONG
//4 Jewish (Tishri, Heshvan, Kislev, etc.) // _MONTH_JEWISH
//5 French Republican (Vendemiaire, Brumaire, Frimaire, ASO) 

//true or false, displays date using Jewish characters

//CAL_ (CALendar)

//timestamp, the timestamp number, you can get it by using DATE functions:
//time(); // the current timestamp (the number of seconds from January 1, 1970 00:00:00 GMT up to now)
//mktime(23,59,59,12,31,2010); //timestamp from the last second of 2010
//mktime(hour, minutes, seconds, month, day, year)

cal_days_in_month(CAL_JULIAN, 10, 2005); // cal_days_in_month(calendar, month, year)
cal_from_jd(2453754, CAL_GREGORIAN); // cal_from_jd(julian_day_count, calendar)
cal_info(); cal_info(CAL_FRENCH); // cal_info(calendar)
cal_to_jd(CAL_GREGORIAN, 12, 31, 2010); // cal_to_jd(calendar, month, day, year)
easter_date(); easter_date(2005); // easter_date(year)
easter_days(); easter_days(1600, CAL_EASTER_ROMAN); //easter_days(year, method)
frenchtojd(12, 30, 5); // frenchtjd(month, day, year)
gregoriantojd(12, 31, 2010); // gregoriantojd(month, day, year)
jddayofweek(2453754); jddayofweek(2453754, 1); // jddayofweek(julian_day_count, mode1)
jdmonthname(2453754); jdmonthname(2453754, 3); // jdmonthname(julian_day_count, mode2)
jdtofrench(2453754); // jdtofrench(julian_day_count)
jdtogregorian(2453754); // jdtogregorian(julian_day_count)
jdtojewish(2453754); jdtojewish(2453754, true, CAL_JEWISH_ADD_ALAFIM); //jdtojewish(julian_day_count, hebrew_display, hebrew_display_type)
jdtojulian(2453754); // jdtojulian(julian_day_count)
jdtounix(2453754); // jdtounix(julian_day_count)
jewishtojd(4, 18, 5766); // jewishtojd(month, day, year)
juliantojd(9, 10, 1999); //juliantojd(month, day, year)
unixtojd(); unixtojd(1137538800); //unixtojd(timestamp)

//parameter: CONSTANTS
//used in functions: cal_days_in_month(), cal_from_jd(), cal_info(), cal_to_jd
//mode1: 0, 1, 2
//used in jddayofweek() function
//mode2: 0, 1, 2, 3, 4, 5
//used in jdmonthname() function
//used in easter_days() function
//used in jdtojewish() function

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.