The Zap Cal Library is an open source PHP library for reading and writing iCalendar files.  The library has been in development for over 10 years supporting the Zap Calendar program, an open source application for the Joomla CMS, and more recently the iCalendar validator project at  It is now available as a standalone library for PHP developers.

The library can be downloaded at GitHub at

The API documentation can be found at

The Zap Calendar iCalendar Library is a PHP library for supporting the iCalendar (RFC 5545) standard. Several examples of reading and writing iCalendar files are included in the library

This PHP library is for reading and writing iCalendar formatted feeds and files. Features of the library include:

  • Read AND write support for iCalendar files
  • Object based creation and manipulation of iCalendar files
  • Supports expansion of RRULE to a list of repeating dates
  • Supports adding timezone info to iCalendar file

All iCalendar data is stored in a PHP object tree. This allows any property to be added to the iCalendar feed without requiring specialized library function calls. With power comes responsibility. Missing or invalid properties can cause the resulting iCalendar file to be invalid. Visit to view valid properties and test your feed using the site's iCalendar validator tool.

Here is an example of a PHP program to create a single event iCalendar file:


$title = "Simple Event"; // date/time is in SQL datetime format $event_start = "2020-01-01 12:00:00"; $event_end = "2020-01-01 13:00:00"; // create the ical object $icalobj = new ZCiCal(); // create the event within the ical object $eventobj = new ZCiCalNode("VEVENT", $icalobj->curnode); // add title $eventobj->addNode(new ZCiCalDataNode("SUMMARY:" . $title)); // add start date $eventobj->addNode(new ZCiCalDataNode("DTSTART:" . ZCiCal::fromSqlDateTime($event_start))); // add end date $eventobj->addNode(new ZCiCalDataNode("DTEND:" . ZCiCal::fromSqlDateTime($event_end))); // UID is a required item in VEVENT, create unique string for this event // Adding your domain to the end is a good way of creating uniqueness $uid = date('Y-m-d-H-i-s') . ""; $eventobj->addNode(new ZCiCalDataNode("UID:" . $uid)); // DTSTAMP is a required item in VEVENT $eventobj->addNode(new ZCiCalDataNode("DTSTAMP:" . ZCiCal::fromSqlDateTime())); // Add description $eventobj->addNode(new ZCiCalDataNode("Description:" . ZCiCal::formatContent( "This is a simple event, using the Zap Calendar PHP library. " . "Visit to validate icalendar files."))); // write iCalendar feed to stdout echo $icalobj->export();