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.