How to change timezone for a node app running inside a container?


#1

How to change timezone for a node app running inside a container?


#4

Hi there. There are some options for that. You should be able to change the timezone, container-wide, by adding the below directives to your Dockerfile:

ENV TZ=Europe/London
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

Alternatively, you can invoke your node app with the TZ envvar set properly, like env TZ='Europe/London' node server.js,
or even from within your app process.env.TZ = 'Europe/London'.
But it would make sense to just use UTC everywhere (as a well established standard) and apply timezone offsets within your app logic.