0

Have a site for training webex events. Our company is located in several different timezones. In the past everything has been converted to Pacific time (where we are headquartered). Trying to focus more on user experience and make things more local and less about HQ.

So all the times are shown in local time, but this is now confusing users because they don't expect it. I'd like to add three letter initials (PST, CMT, EST, HAST or HST, etc.)

As I'm looking into this I'm keep getting referred back to moment timezone. We are already using moment for other date/time stuff, so that would be awesome.

But all the timezone examples are like this:

moment.tz([2012, 0], 'America/New_York').format('z'); // EST

Basically it seems like you already need to know what timezone the user is in. If I already knew what timezone they were in I wouldn't need moment to tell me. Also the documentation says:

...By default, moment objects are created in the local time zone....

I'm located in Portland, Oregon, javascript new Date() shows (PST) (in Chrome at least), but moment.tz().zoneAbbr() is UTC, so clearly not my local time zone.

I found this thread that recommends using jsTimezoneDetect.

moment.tz(new Date(), jstz.determine().name()).format('z')

I understand why this is a complex thing given locations around the world and different daylight savings schemes. But I have to wonder -- am I missing something? Is there some easier way to do this?

Community
  • 1
  • 1
Rothrock
  • 1,413
  • 2
  • 16
  • 39

0 Answers0