Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get client local timezone in js

I want to get the client machine local timezone.

I tried moment-timezone npm package, with the following command

moment.tz().zoneAbbr()

But it is giving me Universal timezone ie UTC, but I want IST

Can anybody please guide me how to get client machine local time zone.

like image 403
khushboom Avatar asked May 05 '26 18:05

khushboom


1 Answers

Intl.DateTimeFormat().resolvedOptions().timeZone will return the client's timezone.

const { timeZone } = Intl.DateTimeFormat().resolvedOptions();

console.log(timeZone);
like image 148
rantao Avatar answered May 08 '26 09:05

rantao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!