我的.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-file):
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
谢谢! :)
答案 0 :(得分:1)
您没有指定任何时区。
这意味着您正在使用“浮动时间”,这会导致日历客户端“猜测”正确的时区。
您应该以UTC格式指定时间(为此,使用Z
结束时间)或使用TZID
属性指定时区。
正式地说,您还必须为您使用的每个VTIMEZONE
添加TZID
块,但只要您使用Olson时区ID,客户就可以毫无问题地工作。