troubleshooting Question

How do you change the default timezone in moment.js?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
6 Comments3 Solutions231 ViewsLast Modified:
I've got some bizarre timeframes showing up in my app and I'm pretty certain it's coming from a default timezone discrepancy in "moment.js."

If you head out to the docs, you find this:

To change the default time zone, use with a valid time zone."America/New_York");
To reset the default time zone to local, use with no arguments.;

I can find "," but it's not followed by "America/New York" or anything that intuitive. Instead, I get this: = function(name) {
            if (major < 2 || (major === 2 && minor < 9)) {
                  logError('Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js ' + moment.version + '.');
            moment.defaultZone = name ? getZone(name) : null;
            return moment;

...and other such pieces of syntax.

I want to believe that this should be fairly easy.

What am I missing?
Join our community to see this answer!
Unlock 3 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros