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:
info:
on: "2020-05-07T10:15:00.000-06:00"
off: "2020-05-07T10:16:00.000-06:00"
info_local:
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.