Existing answers will tell you the current time zone offset, but you will have problems if you compare historical / future time points, as this will not take into account daylight saving time changes.
In many time zones, the offset changes throughout the year, and these changes occur on different dates or not at all, depending on latitude. If you only have UTC time and offset, you can never be sure what offset will be in this place at other times of the year.
For example, a UTC + 2: 00 offset may apply to Barcelona in the summer or CΓ΄te d'Ivoire year-round. A 2-hour shift will always display the correct time in CΓ΄te d'Ivoire, but in Barcelona it will be 1 hour within six months.
Check out this article covering above.
How do we handle all these time zone issues? Well, this is pretty simple:
- Save all time in UTC
- Save the name of the time zone where it happened
In modern browsers, you can get the IANA local time zone string, for example:
Intl.DateTimeFormat().resolvedOptions().timeZone
You can then use this time zone line in a library such as Luxon to help offset your captured UTC time.
DateTime.fromISO("2017-05-15T09:10:23", { zone: "Europe/Paris" });
source share