Terminexport als iCal

Folgendes Format muss rauskommen:

BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//Thomas Multimedia//Clinic Time//EN
BEGIN:VEVENT
SUMMARY:Emily Henderson
UID:3097
STATUS:CONFIRMED
DTSTART:20120509T031500Z
DTEND:20120509T033000Z
LAST-MODIFIED:20120509T031500Z
LOCATION:Bundall Clinic Room 1
END:VEVENT
END:VCALENDAR

Mit PHP in einer Schleife folgendes bauen:

getProfileId())->getName();
     $output .=
"BEGIN:VEVENT
SUMMARY:" . $appointment->getProduction()->getHeadline() ."
UID:" . md5($appointment->getId() . $appointment->getDate()) ."
DTSTART:" . str_replace(array('-', ':'), array('',''), date(DATE_ICAL, strtotime($appointment->getDate('Y-m-d') . ' ' . $appointment->getStartTime()))) . "
DTEND:" . str_replace(array('-', ':'), array('',''), ($appointment->getEndTime() ? date(DATE_ICAL, strtotime($appointment->getDate('Y-m-d') . ' ' . $appointment->getEndTime())) : date(DATE_ICAL, strtotime($appointment->getDate('Y-m-d') . ' ' . $appointment->getStartTime()) + 3600))) . "
STATUS:CONFIRMED
LAST-MODIFIED:" . str_replace(array('-', ':'), array('',''), date(DATE_ICAL, strtotime($appointment->getLastModified()))) . "
LOCATION:$location
END:VEVENT\n";
}
$output .= "END:VCALENDAR";

header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=spielplan.ics');
echo $output;
 
?>

Quelle