简体   繁体   中英

Displaying ical calendar event in local time depending on timezone

Our timetabling system creates lecture events in Europe/London timezone. Now that everybody is using the webbased distance learning system, people are using it across different parts of the world. Lectures timetable system can generate events only in London timezone. How do I display event to user in his own timezone? Lets say if user is in America-NewYork and click on his lecture, I need to capture his timezone and convert event entry to his timezone.

VEVENT BEGIN:VEVENT 
DTSTART;
TZID=Europe/London:20191001T140000 
DTEND;TZID=Europe/London:20191001T160000
DTSTAMP:20200523T165523 
UID:285F71
CLASS:PUBLIC CREATED:20200523
LAST-MODIFIED:20200523T165523 
SEQUENCE:0 
STATUS:CONFIRMED 
SUMMARY:SPA5219-A19 Thermodynamics Lecture 
DESCRIPTION:SPA5219-A//Lecture/01 ABC
LOCATION:SP:OPAQUE 
END

If you are using php, you would create the datetime object for the event and then set the timezone using https://www.php.net/manual/en/datetime.settimezone.php . It will handle all the daylight saving and timezone differences etc for you. Then when you output the date and time using https://www.php.net/manual/en/datetime.format.php it will be in the timezone you have chosen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM