-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node:8-alpine wrong timezone behavior #626
Comments
You need to run the following RUN apk --update add \
tzdata \
&& cp /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
&& apk del tzdata Info from gliderlabs/docker-alpine/issues/136 |
Closing as it seems answered? Happy to reopen |
This issue is not exactly answered. Having this same issue on node:10-alpine. Tried solution above and whatever I could find in gliderlabs/docker-alpine/issues/136. But to no avail. When doing console.log(new Date()) the issue persists in node.js; time differs minus 2 hours from what busybox says when running the date command. |
I had the same issue and found that setting environment variable TZ in the Dockerfile solves it. At least for me it did.
|
Having same issue don't know what the problem is. Running date in the shell returns the correct time but running new Date in the node REPL returns current time minus 2hrs which seems to be GMT at the time of this writing. Also can't get nodecron to work properly when setting the timezone there instead, it works against the same offset.
|
new Date is returned in UTC https://tc39.es/ecma262/#sec-date-constructor-date |
@nschonni |
Just ran into this myself on node:12-alpine:
I'm guessing this means node depends on the TZ environment variable being set. Although, the 2 hours off thing is just strange. |
Hi all,
I have found a strange behavior in node:8-alpine. Some methods of the Date object return incorrect values.
The getTimezoneOffset() method return 0 instead of -60 for Paris TZ
Also the getHours method return the non local hour:
But the toLocaleTimeString method return the correct hour.
So it seem that the methods getHours don't take into account the TZ env var.
The text was updated successfully, but these errors were encountered: