get client time zone from browser [duplicate]

Half a decade later we have a built-in way for it!
For modern browsers I would use:

const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
console.log(tz);

This returns a IANA timezone string, but not the offset. Learn more at the MDN reference.

Compatibility table – as of March 2019, works for 90% of the browsers in use globally. Doesn’t work on Internet Explorer.

Leave a Comment