I'm a code butcher but feel free to use any below to get the idea going. This is part of a controller I did for generating a calendar file for a video that was sent with a button to add to ical:
$ical = " BEGIN:VCALENDAR VERSION:2.0 CALSCALE:GREGORIAN BEGIN:VEVENT UID:" . md5(uniqid(mt_rand(), true)) ."".$domain." DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . " DTSTART;TZID=".$dealer->timezone.":".str_replace('-', '', $date)."T".str_replace(':', '', $startTime)." DTEND;TZID=".$dealer->timezone.":".str_replace('-', '', $date)."T".str_replace(':', '', $endTime)." SUMMARY:".$subject." LOCATION:".$video->FromAddress.", ".$video->FromCity." ".$video->FromPostal." DESCRIPTION:".$desc." URL:http://www.somesite.com" BEGIN:VALARM TRIGGER:-PT30M DESCRIPTION:Appointment Reminder ACTION:DISPLAY END:VALARM END:VEVENT END:VCALENDAR"; header('Content-type: text/Calendar; charset=utf-8'); header('Content-Disposition: inline; filename=calendar.ics'); echo $ical;