You can download the class here.
The PHP Calendar is a class that generates a calendar for a given month and year. Best of all, it is extremely easy to use and can easily be extended to do whatever you want.
Creating and displaying the calendar is very easy and can be done with only two lines of code.
1 2 | $calendar = new Calendar(1, 2009); $calendar->generate(); |
The constructor takes in two variables. The first one for the month, and the second one for the year. The generate() method generates the calendar in an HTML table.
There are a number of functions in the class that modify the way the calendar renders.
shortMonthTags() – Show the month as three letter abbreviation instead of the entire month name
longMonthTags() – Show the full month name (default functionality)
longDayTags() – Show the days with their full name
shortDayTags() – Show the tags with their single character abbreviations (default functionality)
addDayLink($day, $url) – Makes the $day number link to $url
getNextMonthYear() – Gets the next month relative to the current calendar month and year
getPreviousMonthYear() – Gets the previous month relative to the current calendar month and year
getCurrentMonthYear() – Gets the current month and year (The real time, not the month and year of the current calendar)
setNextMonthContent($string) – Sets the content of the box to the right of the Month and Year. Generally this will be a link to the next month.
setPreviousMonthContent($string) – Sets the content of the box to the left of the Month and Year. Generally this will be a link to the previous month.
set($var, $val) – Universal set function. Set any $var with the value $val.