Moment-timezone: Get offset in seconds from a specific timezone to utc

Created on 26 Aug 2015  路  4Comments  路  Source: moment/moment-timezone

I am trying to get the offset in seconds from America/New_York to UTC, and according to the doc I should be able to do:

moment.tz('America/New_York').utcOffset()

But I am getting:

moment.tz is not a function

Most helpful comment

@RangerMauve

moment.tz(moment.utc(), 'America/New_York').utcOffset()
// -240 min

All 4 comments

  1. You need to load both moment and moment-timezone. It sounds like you only have moment loaded.
  2. You can't get an offset from a time zone without a specific moment in time. Many time zones have changed their offsets over their history, or use a different offset when DST is in effect.

Note, the syntax you showed here is valid - but it uses the _current_ offset, because no date or time information was passed in the tz function.

Hi, sorry to bump this, but could you provide an example of how to actually supply the instant in time to use? For example, the current time?

@RangerMauve

moment.tz(moment.utc(), 'America/New_York').utcOffset()
// -240 min
Was this page helpful?
0 / 5 - 0 ratings