我的 .ics 文件未在 Google Cal 中显示正确的时区。在 iCal 和 iPhone 和 iPad 上它会正确显示。我真的看不出有什么问题!
时区必须设置为哥本哈根时间:)
<?php
date_default_timezone_set('Europe/Copenhagen');
include("includes/db_connect.php");
$schedules = "BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
PRODID:HG Kalender";
$schedules .= "-//Drupal iCal API//EN";
$result=mysql_query("SELECT * FROM `x`");
while($rows=mysql_fetch_array($result)){
$overskrift = $rows['overskrift'];
$date = $rows['date'];
$month = $rows['month'];
$year = $rows['year'];
$start_hour = $rows['start_hour'];
$start_minute = $rows['start_minute'];
$end_hour = $rows['end_hour'];
$end_minute = $rows['end_minute'];
$end_place = $rows['end_place'];
$start_place = $rows['start_place'];
$info = $rows['info'];
$idets = $rows['id'];
$ics_dato = $year.$month.$date;
$start_hour = $start_hour;
$end_hour = $end_hour;
$ics_starttidspunkt = $start_hour.$start_minute."00";
$ics_sluttidspunkt = $end_hour.$end_minute."00";
$schedules .= "\nBEGIN:VEVENT";
$schedules .= "\nUID:" . time().rand(11111, 99999);
$schedules .= "\nDTSTAMP:" . date("Y-m-d H:i:s");
$schedules .= "\nDTSTART:" . date("$ics_dato", $strDate)."T".date("$ics_starttidspunkt");
$schedules .= "\nLOCATION:".$start_place;
$schedules .= "\nDTEND:". date("$ics_dato",$endDate)."T".date("$ics_sluttidspunkt");
$schedules .= "\nSUMMARY:".$overskrift;
$schedules .= "\nURL:x.com;
$schedules .= "\nDESCRIPTION:text;
$schedules .= "\nEND:VEVENT";
}
$schedules .= "\nEND:VCALENDAR";
header( "Content-type: text/calendar");
header("Expires: 0");
file_put_contents("x.ics",$schedules);
?>
输出(.ics 文件):
BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
PRODID:HG Kalender-//Drupal iCal API//EN
BEGIN:VEVENT
UID:136869502441928
DTSTAMP:2013-05-16 11:03:44
DTSTART:20130622T100000
LOCATION:Holbæk Stadion
DTEND:20130622T160000
SUMMARY:Tattootræning
URL:x.com
DESCRIPTION:text
END:VEVENT
END:VCALENDAR
谢谢!:)