I looked into the internet but all I could find was getTimezoneOffset()
javascript function. But it gives me offset not the timezone, the client is in. Please guide me.
Asked
Active
Viewed 577 times
0

Unbreakable
- 7,776
- 24
- 90
- 171
-
try using `toTimeString()` – sam Nov 09 '16 at 16:45
-
Every one in the link you have mentioned is talking about the offset and not answering the original question. So my question is precise and different (even though it looks same). Kindly go through the link and its answers. You will realize that the answers are not in sync with what was asked. If you are convinced remove the tag of "duplicate". If not then never mind. – Unbreakable Nov 09 '16 at 17:28
2 Answers
0
Did you try the getTimezoneOffset() this way?
var offset = new Date().getTimezoneOffset();
console.log(offset);
Because it works for me.

Eros Hernández
- 58
- 1
- 6
-
1it gives you the offset. I want to know the timezone. Your code returns the minutes local time if off from GMT or UCT. I want something like "IST" or "GMT" or "EST" or "PCT" the user has logged in from. Am I making sense? – Unbreakable Nov 09 '16 at 16:48
-
@Unbreakable - see [this answer](http://stackoverflow.com/a/28377706/634824) and [this one](http://stackoverflow.com/a/40495632/634824) regarding abbreviations. See the dup post link at the top if you want an actual time zone identifier. – Matt Johnson-Pint Nov 09 '16 at 21:40
0
If you are looking for timezone specifically.
var date = new Date();
console.log(date.toString());
//Wed Nov 09 2016 22:21:53 GMT+0530 (IST)
console.log((/\((.+)\)/g).exec(date.toString())[1]);
//IST

sam
- 931
- 2
- 13
- 26
-
The problem here is that the value in parenthesis is implementation specific. It will sometimes be an abbreviation, sometimes a language-specific time zone name, and sometimes nothing at all. It is not covered by the ECMAScript specification. – Matt Johnson-Pint Nov 09 '16 at 21:38