Bruce Gust
asked on
How do you change the default timezone in moment.js?
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 moment.tz.setDefault with a valid time zone.
moment.tz.setDefault("Amer ica/New_Yo rk");
To reset the default time zone to local, use moment.tz.setDefault with no arguments.
moment.tz.setDefault();
I can find "moment.tz.setDefault," but it's not followed by "America/New York" or anything that intuitive. Instead, I get this:
moment.tz.setDefault = 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?
If you head out to the docs, you find this:
To change the default time zone, use moment.tz.setDefault with a valid time zone.
moment.tz.setDefault("Amer
To reset the default time zone to local, use moment.tz.setDefault with no arguments.
moment.tz.setDefault();
I can find "moment.tz.setDefault," but it's not followed by "America/New York" or anything that intuitive. Instead, I get this:
moment.tz.setDefault = 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?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you,boys! I'm going to let my team lead determine how he wants to handle this, but your counsel gives me what I need to sound intelligent when I talk to him.
Thanks!
Thanks!
You're welcome!
Good luck!
Good luck!
and second example don't have