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

$calendar = new Calendar('2008-02-08');
$calendar->highlighted_dates = array(

$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.

$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.

$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


  1. Quinn Perkins

    # March 10, 2008 - 2:33 am

    Sorry to have to post this here, but I’ve been looking on your site for some time now for contact information for you. I had a question about the license for your calendar PHP class. Can you point me towards your contact info?

  2. dmsuperman

    # March 11, 2008 - 9:31 am

    I would like to use your calendar class for a commercial project my company ( is working on. If you require specifics, please email me your email so I can send them to you. If this is allowable, please email me saying so.

    On a more personal note, love the class. Using it for my own personal portfolio at home ;)

Leave a Reply