A group about Web Design & Development. Ask and Learn everything related to web design and development.

Post tutorial Report content RSS feed 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:
W3schools.com

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

<?php

//calendar:
//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

//julian_day_count:
//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)
//_EASTER_DEFAULT
//_EASTER_ROMAN
//_EASTER_ALWAYS_GREGORIAN
//_EASTER_ALWAYS_JULIAN

//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) 

//hebrew_display
//true or false, displays date using Jewish characters

//hebrew_display_type
//CAL_ (CALendar)
//_JEWISH_ADD_ALAFIM_GERESH
//_JEWISH_ADD_ALAFIM
//_JEWISH_ADD_GERESHAYIM

//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)
//or:
//mktime(23,59,59,12,31,2010); //timestamp from the last second of 2010
//pattern:
//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
//calendar: CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH, CAL_FRENCH
//used in functions: cal_days_in_month(), cal_from_jd(), cal_info(), cal_to_jd
//mode1: CAL_DOW_DAYNO, CAL_DOW_LONG, CAL_DOW_SHORT // or:
//mode1: 0, 1, 2
//used in jddayofweek() function
//mode2: CAL_MONTH_GREGORIAN_SHORT, CAL_MONTH_GREGORIAN_LONG, CAL_MONTH_JULIAN_SHORT, CAL_MONTH_JULIAN_LONG, CAL_MONTH_JEWISH, CAL_MONTH_FRENCH // or:
//mode2: 0, 1, 2, 3, 4, 5
//used in jdmonthname() function
//method: CAL_EASTER_DEFAULT, CAL_EASTER_ROMAN, CAL_EASTER_ALWAYS_GREGORIAN, CAL_EASTER_ALWAYS_JULIAN
//used in easter_days() function
//hebrew_display_type: CAL_JEWISH_ADD_ALAFIM_GERESH, CAL_JEWISH_ADD_ALAFIM, CAL_JEWISH_ADD_GERESHAYIM
//used in jdtojewish() function

?>
Post a comment

You are not logged in, your comment will be anonymous unless you join the community. Or sign in with your social account:

Established
Privacy
Public
Subscription
Open to all members
Contact
Send Message
Membership
Join group
Group watch
Start tracking
Tutorial
Browse
Tutorials
Share
Related Groups
Inside the Page
Inside the Page Hobbies & Interests with 55 members
Web devs & web game devs
Web devs & web game devs Hobbies & Interests with 43 members