Reputation: 13
My .ics-file doen't show the right time-zone in Google Cal. In iCal and on iPhone & iPad it is shown currectly. I really can't see what's wrong!
The timezone has to be set Copenhagen-time :)
<?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);
?>
The output (.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
Thanks! :)
Upvotes: 1
Views: 2342
Reputation: 99505
You're not specifying any timezone.
This means that you're using 'floating time', which will cause calendaring client to just 'guess' the correct timezone.
You should either specify the times in UTC (to do this, end the time with a Z
) or use the TZID
property to specify the timezone.
Officially you must also include the VTIMEZONE
block for every TZID
you use, but as long as you use the Olson Timezone Id, clients tend to work without issue.
Upvotes: 3