Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 1
    Thank you! After much searching, I finally found my answer here. Much appreciated.
    – Armando
    Commented Jul 1, 2021 at 12:48
  • Note, it won't always work because in "short" format some timezones are represented by their name like "PST" rather than their offset. The better approach would be to print timezone in "shortOffset" format, but this option is not supported in Node.js. Commented Jan 16, 2022 at 21:43
  • Node.js now supports the "shortOffset" and "longOffset" options for timeZoneName. Commented Jun 24, 2022 at 2:22
  • 1
    Good answer. However, it needs a tweak. The line that scaps the number from the text do not work for timezones that resolve to GMT instead of GMT+0. I will update the answer to add a fix.
    – asiby
    Commented Jun 24, 2022 at 15:19
  • @AlexanderKorostin, using "longOffset" as timezone format will solve that. I have edited the answer again to address that.
    – asiby
    Commented Jun 24, 2022 at 16:41