20130426 -- 这是 YYYYMMDD 格式 133000Z - 1330 是格林威治标准时间 00Z 只是一些额外的文本
嘿,我这周刚刚在做这个,这是我用来做的代码:
// DISPLAY CALENDER EVENT
$startdate = date('Ymd',strtotime($startdate)); //needs the YYYYMMDD format
$enddate = date('Ymd',strtotime($enddate)); //ends the day before the set date. So the date range is startdate(inclusive) -> enddate(exclusive)
$startTime = gmdate('Hi',mktime($startminutes,$startseconds)); // This is in greenwhich mean time. Have the users input time normally and simply
//explode on :
$endTime = gmdate('Hi',mktime($endminutes,$endseconds));
$subject = 'yeah';
$desc = 'come to this meeting';
$location = 'wherever';
$ical = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true))."
DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
DTSTART:".$startdate."T".$startTime."00Z
DTEND:".$enddate."T".$endTime."00Z
LOCATION:$location
SUMMARY:".$subject."
DESCRIPTION:".$desc."
END:VEVENT
END:VCALENDAR";
//set correct content-type-header
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
echo $ical;
这个网站帮助做到了这一点:http ://www.daveismyname.com/development/adding-events-to-microsoft-outlook-from-php-using-ical/