Time zone in icalendar or vcalendar meeting invita

2019-01-27 03:28发布

问题:

I am sending calendar meeting request via PHP and following code, I am using.

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20150501T080000Z
DTEND:20150502T090000Z
DTSTAMP:20150411T075116Z
ORGANIZER;CN=Jass:mailto:organizer@google.com
UID:12345678
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Sample:mailto:sample@test.com
DESCRIPTION:Complete event on http://www.sample.com/get_event.php?id=12345678
LOCATION: India
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:TESTING timezones
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

Problem

I am sending request from 8am to 9am but in invitation, I am getting from 1:30pm to 2:30pm.

so how to manage time zone in this case?
What is DTSTAMP and can we manage this problem via DTSTAMP?

回答1:

The "Z" suffix in your DTSTART and DTEND indicates that those datetime are provided in UTC. Assuming that your client has a timezone set to India (UTC + 5h30), it correctly displays the start time as being 1:30PM.

So you either need to take that into account when sending your invite, or include a VTIMEZONE component in your invitation and reference that VTIMEZONE in your DTSTART/DTEND:

...
METHOD:REQUEST
BEGIN:VTIMEZONE
TZID:Asia/Kolkata
BEGIN:STANDARD
TZOFFSETFROM:+0530
TZOFFSETTO:+0530
DTSTART:19451015T000000
TZNAME:IST
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Asia/Kolkata:20150501T080000
DTEND;TZID=Asia/Kolkata:20150501T090000

...

The DTSTAMP is used mainly to see whether an update to an existing event is later than what the client has already received. See https://tools.ietf.org/html/rfc5545#section-3.8.7.2