DEV Community

Discussion on: Adding events to calendar automatically from email

Collapse
 
mohitmehta1996 profile image
mohitmehta1996

Brother, your event will show incorrect time when user is from different timezone. So we should always set time in UTC.

Collapse
 
arxeiss profile image
Pavel Kutáč • Edited

Hi, in this case it really depends on your Laravel settings. The config/app.php file. If you have there set UTC, the invitation will be in UTC. When I set there Europe/Prague, it has in invitation Europe/Prague. But whatever setting you use, it will include timezone details. So it will work for users with different timezone too.

This is result from the code above. So it has timezones and also info about standard and daylight time.

BEGIN:VCALENDAR\r\n
VERSION:2.0\r\n
PRODID:Kutac.cz\r\n
METHOD:REQUEST\r\n
BEGIN:VTIMEZONE\r\n
TZID:Europe/Prague\r\n
BEGIN:DAYLIGHT\r\n
DTSTART:20210328T030000\r\n
TZOFFSETFROM:+0100\r\n
TZOFFSETTO:+0200\r\n
END:DAYLIGHT\r\n
BEGIN:STANDARD\r\n
DTSTART:20211031T030000\r\n
TZOFFSETFROM:+0200\r\n
TZOFFSETTO:+0100\r\n
END:STANDARD\r\n
BEGIN:DAYLIGHT\r\n
DTSTART:20220327T030000\r\n
TZOFFSETFROM:+0100\r\n
TZOFFSETTO:+0200\r\n
END:DAYLIGHT\r\n
END:VTIMEZONE\r\n
BEGIN:VEVENT\r\n
UID:61bcf1ac5cf93\r\n
DTSTAMP;TZID=Europe/Prague:20211217T212308\r\n
SUMMARY:Email with iCal 101\r\n
LOCATION:Online - Google Meet\r\n
ATTENDEE:MAILTO:attendee@gmail.com\r\n
DTSTART;TZID=Europe/Prague;VALUE=DATE:20211215\r\n
DTEND;TZID=Europe/Prague;VALUE=DATE:20211219\r\n
END:VEVENT\r\n
END:VCALENDAR
Enter fullscreen mode Exit fullscreen mode