How to config moment timezone in Meteor Project?


#1

I would like to config default moment tiemzone in my project.
Please help me.


#2
Meteor.startup(function() {
  moment.tz.setDefault("America/New_York");
});

Have a look at the online documentation.


#3

Thanks, it work for client only?


#4

It should work on the server too.


#5

So could I use in common folder?


#6

Yes, it should work.


#7

I tried but don’t work Cannot call method 'setDefault' of undefined.


#8

This is probably because the Moment Timezone library is not loaded on the server side. Where/how did you added the library?


#9

I added momentjs:moment


#10

I’m unsure if the Timezone component of Moment is part of this package. You may have to add it manually.


#11

What do you think dispatch:date-tools?


#12

In general i would not advise you to use the atmosphere wrapper packages for third party code like moment.js – they are always lagging behind and you loose a lot of control.

I go with standard bower (http://bower.io/) which is always up to date and easier to manage your third party dependencies. Then include them like any other file (e.g: api.addFiles([‘bower_components/moment/moment.js’]); in your package.js


#13

meteor add mrt:moment-timezone