how can I get the GMT offset in javascript of the client?
new Date().getTimezoneOffset();
returns the difference from UTC. Is there a way I can calculate the GMT offset from that?
By GMT offset, I mean as in -5 for eastern standard time.
javascripttimetimezonetimezone-offset
how can I get the GMT offset in javascript of the client?
new Date().getTimezoneOffset();
returns the difference from UTC. Is there a way I can calculate the GMT offset from that?
By GMT offset, I mean as in -5 for eastern standard time.
Best Answer
The timezone offset is the difference from GMT in minutes (see ECMA-262 §15.9.5.26). The sign is the reverse of ISO 8601, but it's easily converted to hours and minutes with a more standard sign:
If you want to determine the IANA timezone designation, you can try pellepim jstimezonedetect, however it works by guessing based on the offset for two dates and may not be correct.