Set timezone on Meteor server

I have been playing with NodeChef and Galaxy.
Loving the hosted options, ease of use kicks ass compared with managing my own DO droplets.
The only issue I have is that I want the server to think its timezone is Australian.

Is there a way I can set the meteor server to have a timezone set globally?

You can set the “TZ” environment variable to whatever time zone and your app will see that reported from the OS

Setting environment variable is through settings.json on galaxy.


If its that simple thats awesome… I will give it a shot.
So for NodeChef I need this:

    "TZ": "Australia/Sydney"

and Galaxy this:

"": {
  "env": {
    "TZ": "Australia/Sydney", 

Yep! But for what its worth, I’d suggest making your app time zone agnostic bu relying on utc at all times and converting to/from utc as date data gets in/out

momentjs and momenttz combination is a great utility for this


Yeah normally I would agree, but the app I am working on pulls data from the local stock exchange.
I need it to follow the local timezone here as it needs to follow the trading day.

Just deployed and it looks like it worked perfectly!!

Thanks :slight_smile:

1 Like

I’m glad it worked out for you :slight_smile:

Would you like to discuss UTC based approaches to tapping onto that data?

1 Like

I really only needed the Timezone thing because I use SyncedCron and only want it to run while the market is open.

I know I could use UTC time, but I don’t know if that would take into account DST, and it’s nice and easy for me with this:


UTC is a bit frustrating because it adds some complexity where it really isn’t needed.

However, to be honest I haven’t really tried it, but I am guessing it would make running queries a bit more difficult…
I can’t just say get me all trades from March, because I mean March in Sydney time.
Mongo will get me all UTC March trades. So I could be out by a whole day and miss some trades and falsely include others… right?

Hm, well, I know UTC conversion is an overhead compared to an all-local approach, and that’s perfectly fine by the way, as long as you know your app will always be local and all of your users will always deal with local time.

That being said, it is not actually that hard because moment-tz is really clever enough to abstract away all the details, including DST data. (PS: you are lucky you don’t live in Turkey. Out government as of last 14 years sporadically decides changing DST switching dates, abandon it altogether and then readapt it just trying to make sure if we ever send a rover to mars, it does get lost :wink: ) (PPS: I know that’s a different problem but just thought it would be cool to demonstrate how working with “interationally-absolute” data can be a life-saver at times)

Furthermore, synced-cron also does have a utc option for you to decide if you want to work with local time or utc.

In the mongo querying case, you could store the date/time information at UTC and then query them using the UTC equivalent of your local query-bounds.

1 Like

Thanks for the detailed post!
You’re points are all really solid, I don’t think UTC is as big of a deal as I originally thought.
I’m more thinking now that I overcomplicated what I was trying to do.

Here is another question for you, what do you think about this idea I also had.
This is different to setting the servers TZ to Australia…

I am storing the date of stock trades. The app doesn’t need to store the actual time (hh:mm:ss) or the timezone – all I need is year, month, day.

How about rather than storing ‘Date’ I just store those three attributes?
It would make it much simpler, I could easily evaluate and query trades for each year or each month. Sorting is simple too.

1 Like

Yeah it is a fairly common approach but with an inherent problem where you want to sort or span durations that spread across months/years, becides you are then no longer able to leverage the native date type of the database with which you can do fast comparisons, sorting, calculations, aggregations etc

But as I said, depending on the level of complexity with your specific requirements, that may be a perfectly viable approach.

1 Like

Yeah that’s a good point, right now I can’t think of any reasons to need complex queries on the dates. The trade info is stored just to build the value of portfolios, the trades are only ever visible when you edit the portfolio and I suspect I will want to be able to filter/sort them in that view.

Thanks again for letting me bounce the ideas around :slight_smile:

1 Like

@serkandurusoy im in a similar position to cstrat, im polling a local market api using the date the server generates and saving the data in mongo but want to be able to run the app anywhere. Do you have time to chat about ways to write timezone agnostic code?

@lucaed if you are offering me a job, please PM me, otherwise, please ask your question here, either I or any one of the friendly community members will be doing their best to keep the conversation going and both your question and its answer will have been recorded in internet history for anyone interested :slight_smile:


Not sure about your particular example.

Mine is all to do with stock trading, so I need to store the end of day value for shares.
So for me to store the date, rather than use a formal date object, I just store:

date: {
  d: 20,
  m: 12,
  y: 2010

This allows me to run queries on particular dates and date ranges pretty easily.