Search code examples
phpcalendaroutlookicalendar

iCalendar daylight saving time


I give my users a link they can use to put their appointments that are on my system in their calendar software like Outlook,... using an iCalendar URL.

I generate the dates in the file using this code:

echo "DTSTART;TZID=" . date_default_timezone_get() . ":" . strftime('%Y%m%d', strtotime($app->app_start)) . 'T' . strftime('%H%M%S', strtotime($app->app_start)) . '' . $eol;
echo "DTEND;TZID=" . date_default_timezone_get() . ":" . strftime('%Y%m%d', strtotime($app->app_end)) . 'T' . strftime('%H%M%S', strtotime($app->app_end)) . '' . $eol;

This always worked correctly. But now we're in daylight saving time and all the appointments that are in daylight saving time appear 1 hour too late in my Outlook. Appointments before DST are okay.

So, for example in my ics:

DTSTART;TZID=Europe/Brussels:20150318T083000 DTEND;TZID=Europe/Brussels:20150318T090000

This shows correctly in my calendar, from 08:30 till 09:00

DTSTART;TZID=Europe/Brussels:20150407T083000 DTEND;TZID=Europe/Brussels:20150407T090000

This is my problem, this shows incorrectly in my calendar: from 09:30 till 10:30.

How can I fix this?


Solution

  • You need to make sure your ics file includes the time zone definition, e.g.

    BEGIN:VTIMEZONE
    TZID:US Mountain Standard Time
    BEGIN:STANDARD
    RRULE:FREQ=YEARLY;BYMONTH=0;BYDAY=+10SU
    DTSTART:16010000T000000
    TZOFFSETFROM:-0700
    TZOFFSETTO:-0700
    END:STANDARD
    END:VTIMEZONE
    BEGIN:VTIMEZONE
    TZID:Eastern Standard Time
    BEGIN:STANDARD
    RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=+11SU
    DTSTART:16011101T020000
    TZOFFSETFROM:-0400
    TZOFFSETTO:-0500
    END:STANDARD
    BEGIN:DAYLIGHT
    RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=+12SU
    DTSTART:16010302T020000
    TZOFFSETFROM:-0500
    TZOFFSETTO:-0400
    END:DAYLIGHT
    END:VTIMEZONE