Archives for : utc

Setting node.js app default timezone

Timezones are … difficult. I can say that based on my >20 years programming experience. They pop up here and there and cause a good amount of headache. I won’t spend too much time here for timezones but I just give a quick tip how to set your SailsJS (or any NodeJS) app to use UTC (GMT) timezone by default.
During the years I’ve learn that it’s best to have everything in UTC in the business and DB layers as a rule of thumb (there are exceptions, of course).

It’s really simple to make your NodeJS app to have UTC as default timezone. Just export an environment variable before you run your app:

export TZ="UTC"
forever --watchDirectory ./ -l logs/log.log --watch app.js