I am creating an iCalendar file from an event in my PHP/Zend Framework based calendar application. I am converting the date/time to UTC to avoid dealing with specifying the time zone with them. If I import a one-time event, Outlook properly interprets the UTC time and displays it in my local time zone (Eastern Time (US & Canada)). When I import a recurring event, Outlook is ignoring the fact that the date/time is in UTC and treats it as "floating".
This is the one-time event that imports properly:
BEGIN:VCALENDAR
PRODID:My Calendar Application
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:[email protected]
DTSTAMP:20110713T143920Z
DTSTART:20110713T110000Z
DTEND:20110713T120000Z
SUMMARY:iCalendar Breakfast
DESCRIPTION:Eat more breakfast!
CATEGORIES:Meals
END:VEVENT
END:VCALENDAR
This is the recurring event that does not import properly:
BEGIN:VCALENDAR
PRODID:My Calendar Application
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:[email protected]
DTSTAMP:20110713T142549Z
DTSTART:20110711T220000Z
DTEND:20110711T230000Z
SUMMARY:iCalendar Dinner
DESCRIPTION:This maps to the iCalendar DESCRIPTION field.
CATEGORIES:Meals
RRULE:FREQ=DAILY;UNTIL=20110715T230000Z;INTERVAL=1
END:VEVENT
END:VCALENDAR
The time should be from 6pm to 7pm for Eastern Time (US & Canada), but is showing as 10pm to 11pm in Outlook.
I was reading the iCalendar spec, and found this little paragraph:
The "DTSTART" and "DTEND" property pair or "DTSTART" and "DURATION" property pair, specified within the iCalendar object defines the first instance of the recurrence. When used with a recurrence rule, the "DTSTART" and "DTEND" properties MUST be specified in local time and the appropriate set of "VTIMEZONE" calendar components MUST be included. For detail on the usage of the "VTIMEZONE" calendar component, see the "VTIMEZONE" calendar component definition.
I was able to use date_default_timezone_get()
like this:
$data[] = 'DTSTART;TZID=' . date_default_timezone_get()
. ':' . $date_start;
Simply making that change fixed the issue, but my ics
file is not iCalendar compliant because I don't know how to generate the "VTIMEZONE" calendar component based on the value from date_default_timezone_get()
.