Node Red, Docker on Synology does not honor the timezone, always selects UTC no matter what

Running on the latest version of Synology as of today, which has Docker and docker compose updated to very recent versions, this is what's in my compose file:

    container_name: nodered
    restart: always
    image: nodered/node-red-docker:v8
    user: root
      - /data/nodered:/data
      - /etc/TZ:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
       - "123:1880"
      - TZ=America/Chicago

Before this Synology and Docker update, I never had an issue with the timezone set correctly within Node Red. In fact, all I needed was to use the TZ environment variable, but even with the added time mount point above it doesn't work.

All my other containers all have the correct timezone with the TZ variable. Only Node-Red has an issue with the wrong timezone.

Is this an issue with Node-RED in Docker? How to fix this?

1 Like

In settings.js add:

process.env.TZ = "America/Chicago";

That did the trick! Thank you.

I'm late to the party, by why did this work? My setup was pretty much the same as the OP's, and I've been struggling for hours to get this to work, and that simple config change did it. Part of me wants to say "hey, thanks!" because it solves my issue, but most of me wants to think that something else is broken.

For example, my host time and zone were correct; the container time and zone were correct, and only Node Red was wrong.

Since it's working, thanks!

How are you setting it and testing it for the container?

Similar as the OP:

- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone
- TZ='America/Detroit'

In the correct spots, of course, just as I do for many other containers. I verify the date and timezone by exec'ing into the container and using date.

From earlier this morning, results of date:

On the server: Thu May 7 09:39:21 EDT 2020
Inside my container: Thu May 7 09:38:21 EDT 2020
On my local machine running browser: Thu May 7 09:38:26 EDT 2020
In Chrome's JS console: Thu May 07 2020 9:41:50 GMT-0400 (Eastern Daylight Time)

The debug window showed the correct time for debug messages. I'm not sure if this comes from the browser or server. Actual message content from the server, as well as node status text (presumably from the server, not the browser) we all off by two hours.

msg.payload['date'] = new Date();
msg.payload['localedate'] = new Date().toLocaleString();
msg.payload['offset'] = new Date().getTimezoneOffset();
msg.payload['iso'] = new Date().toISOString();
msg.payload['tzname'] = Intl.DateTimeFormat().resolvedOptions().timeZone;

Gave me this:

date: "2020-05-07T13:49:03.895Z"
localedate: "5/7/2020, 7:49:03 AM"
offset: 360
iso: "2020-05-07T13:49:03.895Z"
tzname: "Etc/GMT+5"

That 360 offset is two hours different than the correct offset, and I have no idea where that's coming from, but might explain the two hour difference.

And today I learned about "Etc", but no idea where that's coming from. The container is properly configured for EDT.

Trying schedex with a 10:15 on an 10:16 off gave me:

on: "2020-05-07T10:15:00.000-06:00"
off: "2020-05-07T10:16:00.000-06:00"

on: "Thu, 07 May 2020 16:15:00 GMT"
off: "Thu, 07 May 2020 16:16:00 GMT"

So it was really confused.

Adding the process.env.TZ fixed everything. It's all perfect now.

1 Like