Javascript Get Browser Timezone String

Timezone string example: America/Los_Angeles

Intl.DateTimeFormat

Intl.DateTimeFormat().resolvedOptions().timeZone

Based on this browser compatibility, it doesn't work on IE11.

moment-timezone

You can use moment-timezone, but the filesize of moment-timezone itself is 171KB (22KB if Gzipped).

Besides, the filesize of moment.js itself is already 453KB, though you can reduce it to 126kB (16KBif Gzipped) by removing the locales.

npm install moment --savenpm install moment-timezone --save
import moment from 'moment'import 'moment-timezone'console.log(moment.tz.guess())

jstimezonedetect

You can also use jstimezonedetect.

npm install jstimezonedetect --save
import jstz from 'jstimezonedetect'console.log(jstz.determine().name())

jstz filesize is 12KB (4KB is Gzipped), but it does comes with some limitation.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.