Search code examples
javascriptmomentjsmoment-timezone

How to get moment-timezone current configured timezone?


So when we configure a default timezone using moment-timezone we do something like this:

moment.tz.setDefault('America/Sao_Paulo')

I was looking for a way to retrieve that value (America/Sao_Paulo) from the moment.tz object... I wasn't able to find it on their documentation page :/ I was assuming it would be something similar to moment.tz.getCurrent() // America/Sao_Paulo

Btw, this is not the same as moment.tz.guess(), because I don't want the user's local timezone, I want literally what is the timezone configured currently on moment, regardless of the browser's timezone.


Solution

  • I'm also in a similar boat. There appears to be an undocumented attribute on moment that is set after you guess the timezone.

    moment.defaultZone
    

    Haven't found how it can be used with other moment-timezone methods yet.