Import ICS into Google Calendar with the correct time zone

I am trying to import a simple ics file into a google calendar. However, although I have a time zone, the Google calendar is still importing the wrong event time. (Although he says the wrong time is in the correct time zone.)

Here is an example of my ics file:

BEGIN:VCALENDAR BEGIN:VEVENT DESCRIPTION: Test_Description DTEND;TZID=US-Pacific:20140606T180000 DTSTART;TZID=US-Pacific:20140606T170000 LOCATION:Test_Location SUMMARY:Test_Summary UID: 20140606T150000@NL END:VEVENT END:VCALENDAR 

This event is due to appear on June 6 from 5pm Pacific Standard Time. However, on my calendar it shows up as June 6th, with 10 AM-11AM PST.

I think (although I haven’t implemented it) to hack just change everything to UTC and adjust the time of the event accordingly. However, this would be a little unpleasant to implement, and frankly, Google Calendar should be able to handle this simple import.

Does anyone have any suggestions on this or any errors in my ICS file?

Thanks!

+6
source share
2 answers

Usually, you want to include VTIMEZONE objects. Many people start skipping this, but if you do, at least use the olson id. This should be enough for the Google calendar to select the correct time zone.

An example of an olson identifier is Europe/Amsterdam . See the identifier that best suits you. Presumably this is something like America/Los_Angeles .

+2
source

For your ICS to work with Google "Add by URL ...", specify the timestamps in UTC and add X-WR-TIMEZONE . The timestamp must have Z at the end to mark the timestamp as UTC:

 DTSTART:20140102T110000Z 

Also add the time zone specification in the VCALENDAR block as follows:

 X-WR-TIMEZONE:Europe/Zurich 

After adding the calendar to Google Calendar, the time zone must be set correctly in the calendar settings.

If you use PHP to create ICS, you can convert timestamps to UTC as follows:

 // The timestamp in your local time and your local time zone $timestamp = "01.01.2016 12:00"; $timezone = new DateTimeZone('Europe/Zurich'); // The UTC timezone $utc = new DateTimeZone('UTC'); // Create a DateTime object from your timestamp using your local timezone $datetime = DateTime::createFromFormat("dmY H:i",$timestamp, $timezone); // Set the timezone on the object to UTC. $datetime->setTimezone($utc); // Print the time in UTC and use the correct format for ICS echo $datetime->format('Ymd\THis\Z'); 

It also works on an Apple iPhone.

+9
source

Source: https://habr.com/ru/post/970109/


All Articles