tgrrr tgrrr - 1 year ago 200
Javascript Question

moment locale not set correctly

We're trying to find a problem with tests that use moment.js and fail when run on a server in Arizona but succeed when run locally here in the UK. We manually set the locale before creating a moment and can see that the local 'en-gb' is installed.

This fiddle highlights what I think the problem is (Need to set computer to Arizona Time zone first!)

// en-gb
// 2016-04-30T17:00:00-07:00

I'm expecting to see the date formatted with respect to 'en-gb' locale but it shows it with respect to Arizona time. Am I missing something?

Answer Source

Locale and timezone are orthogonal things. A locale does not specify a timezone unambigously. You need to set your timezone separately. You can use Momemt Timezone, and then you can use e.g.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download