calendar.class.php update (version 2.5) now available!
I have just released a new version of my PHP calendar generation class. This new version (version 2.5) implements some features users have requested in comments on this site.
You can now specify the starting day of the week. The calendar can be set to only link the days specified in the $highlighted_dates array and, you can now supply a formating string for constructing the links. The last feature allows you to integrate the calendar into sites and applications using Cruft-free URLs.
Users of calendar.class.php have requested a way to only have selected dates (dates passed into the $highlighted_dates array) be linked, while all other dates are not. The $link_days property now accepts the value 2, to trigger this behavior
require_once('calendar.class.php'); $calendar = new Calendar('2008-02-08'); $calendar->highlighted_dates = array( '2008-02-03', '2008-02-14', '2008-02-25' ); $calendar->link_days = 2; echo $calendar->output_calendar();
Flexible formating of the URL that dates link to is now possible thru a new property, $formatted_link_to. Simply provide a string containing PHP date() function compatible parameters (see PHP date() function documentation). Not only does this new feature allow better control of the URL that days link to, it also allows calendar.class.php to integrate into applications utilizing Cruft-free URLs.
require_once('calendar.class.php'); $calendar = new Calendar('2008-02-08'); $calendar->formatted_link_to = '/%Y/%m/%d'; echo $calendar->output_calendar();
Please note that the $link_to property is now depreciated. If a formatting string is present in $formatted_link_to it will override the value of the $link_to property!
Another feature users of calendar.class.php have requested is the ability to set the week’s starting day. The new property $week_start_on accepts a numeric value representing the day of the week that weeks should start with. The values follow that of PHP’s various date functions, ie 0 = Sunday thru 6 = Saturday. This new featured should be especially useful for those creating localized calendars.
require_once('calendar.class.php'); $calendar = new Calendar('2008-02-08'); setlocale(LC_ALL, 'es_ES'); $calendar->week_start_on = 1; echo $calendar->output_calendar();
As before, leave comments or email me with questions, suggestions or to request a licensing exemption to use this class in your commercial works. (Remember calendar.class.php is released under Creative Commons Attribution-Share Alike 3.0 License)
Download the new version: calendar.class.php v2.5
Previous discussions for calendar.class.php