Reputation: 3549
I want to access timezoneId of client. For this I had tried different approaches to get timezoneId information. Like:
I am getting the result but exact results (for all timezones) For example two countries having same offset value then I am unable to locate exact one based on their system timezone setting; like:for Arizona and Mountain Time(US & Canada) both having offset value is UTC-7.00
Right now for both the value it is giving "MST" i.e. Mountain Standard Time as timezoneId. But I want what ever I will configure means if I will select Arizona then it will return Arizona and if I will select Mountain Time(US & Canada) then it will give its corresponding timezoneId.
Can you help me to get exact timezoneId ?
Thanks,
Upvotes: 2
Views: 297
Reputation: 445
Try this,
var d = new Date();
var n = d.toString();
//This will give you like MST, according to browser's time
var timeZone = (n.split("(")[1]).replace(")", "");
Upvotes: 1
Reputation: 628
There is small lib jsTimezoneDetect. It should give you America/Arizona, etc.
Upvotes: 1