How can I gather the visitor's time zone information?
I need both:
- the time zone (for example, Europe/London)
- and the offset from UTC or GMT (for example, UTC+01)
javascripttimezone
How can I gather the visitor's time zone information?
I need both:
Best Answer
Using an offset to calculate Timezone is a wrong approach, and you will always encounter problems. Time zones and daylight saving rules may change on several occasions during a year, and It's difficult to keep up with changes.
To get the system's IANA timezone in JavaScript, you should use
As of April 2023, this works in 95.42% of the browsers used globally.
Old compatibility information
ecma-402/1.0 says that
timeZone
may be undefined if not provided to constructor. However, future draft (3.0) fixed that issue by changing to system default timezone.in ecma-402/3.0 which is still in a draft it changed to