Get timezone offset from timezone name using Javascript

Hardik Sondagar picture Hardik Sondagar · Jan 24, 2014 · Viewed 17.9k times · Source

I found many solution that gives Timezone name from offset value. But I have Timezone name and I want offset value for that. I tried setTimezone('Asia/Kolkata'), but I think their is no method like setTimezone.

example:

Asia/Kolkata should give me -330 ( offset )

Answer

Matt Johnson-Pint picture Matt Johnson-Pint · Jan 24, 2014

You can't get it by name alone. You would also need to know the specific time. Asia/Kolkata may be fixed to a single offset, but many time zones alternate between standard time and daylight saving time, so you can't just get the offset, you can only get an offset.

For how to do it in JavaScript, see this answer.