iCalReader problem
Posted: Thu Aug 26, 2010 11:53 am
Hi,
this is my first topic in this forum :)
I'm having some trouble with iCalReader. I want to display the upcoming dates, and in this case only the first 6 dates. But the problem is that with the code shown below, it counts 6 dates of all the dates, not only the upcoming ones. I hope you understand.
Any easy solution to this?
this is my first topic in this forum :)
I'm having some trouble with iCalReader. I want to display the upcoming dates, and in this case only the first 6 dates. But the problem is that with the code shown below, it counts 6 dates of all the dates, not only the upcoming ones. I hope you understand.
Any easy solution to this?
Code: Select all
<?php
# you need the iCalReader found here:
# http://aidanlister.com/repos/v/iCalReader.php
require_once 'iCalReader.php';
$ical = new iCalReader('konserter.ics');
$meta = $ical->getMeta();
$events = $ical->getEvents();
#compare dates function
function compare_date($a, $b)
{
return strnatcmp($a['DTSTART;TZID=Europe/Oslo'], $b['DTSTART;TZID=Europe/Oslo']);
}
# sort arrays after the dates
usort($events, 'compare_date');
for ($row = 0; $row < 6; $row++)
{
$today = date('Ymd');
$date = substr($events[$row]["DTSTART;TZID=Europe/Oslo"], 0, ;
$year = substr($events[$row]["DTSTART;TZID=Europe/Oslo"], 0, 4);
$month = substr($events[$row]["DTSTART;TZID=Europe/Oslo"], 4, 2);
$day = substr($events[$row]["DTSTART;TZID=Europe/Oslo"], 6, 2);
$time = substr($events[$row]["DTSTART;TZID=Europe/Oslo"], 9,4);
if ($date >= $today){
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>";
}
}
?>