Docker Container: time/timezone wrong Docker Container: time/timezone wrong docker docker

Docker Container: time/timezone wrong


>> Tue May 17 2016 15:12:43 GMT+0200 (CEST)

and

>> Tue May 17 2016 13:13:01 GMT+0000 (Europe)

are approximately the same time(around 18sec difference, because you didn't ran the commands at the same time).Take a closer look, it's around 3pm GMT+0200 and around 1pm GMT+0000.This is just a difference in output format, but the time is the same.If you execute .getTime() on the value of the new Date(), you will probably have the same values.This is probably due to differences in default output format in different node.js versions.


I do it in this way:args: ["-v /etc/timezone:/etc/timezone:ro","-v /etc/localtime:/usr/share/zoneinfo/Europe/Prague:ro", '-e TZ=Europe/Prague']

Need to install timedatectl


I was surprised to see the same problem when using new Date().toString() in a container. It always returns the string for GMT+000, and not for the server's time zone. There might be container-specific settings to change the time zone, but since I know my time zone - New York, I just used toLocaleString:new Date().toLocaleString("en-US", {timeZone: "America/New_York"})