/ Published in: PHP
You can find the ical reader here: http://www.phps.com/scripts/iCalReader.php
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<table id="cal"> <?php # you need the iCalReader found here: # http://www.phps.com/scripts/iCalReader.php // These define() lines go at the top of the script # set the number of events you want to show // Use the DTSTART constant in the compare_date() function require_once 'iCalReader.php'; $ical = new iCalReader('konserter.ics'); $meta = $ical->getMeta(); $events = $ical->getEvents(); #compare dates function function compare_date($a, $b) { } # sort arrays after the dates // Get and sort the events here // This needs to be calculated only once, so put it outside the loop // Save the count to a variable to avoid unnecessary calculations // Loop through all events until either there are no more events or // the maximum number of recent events has been found for ($row = 0, $hits = 0; $row < $count && $hits < MAX_EVENTS; $row++) { // It's possible that some events will not have the appropriate key, // so skip those events continue; } if ($date >= $today) { // Increment the number of events found $hits++; // Move these operations inside this block to avoid unnecessary calculations //$time = substr($events[$row][DTSTART], 9, 4); // Unused? // This looks cleaner (in my opinion), but the format does not matter echo '<tr>' . '<td class="summary">' . $events[$row]['SUMMARY'] . '</td>' . '<td class="date">' . '<span class="day">' . $day . '/</span>' . '<span class="month">' . $month . '/</span>' . '<span class="year">' . $year . '</span>' . '</td>' . '</tr>' . "\n"; } } ?> </table>