1

我无法在 nodejs 中获得与 digitalocean droplet 相同的时间。我在 Ubuntu 20.04 上运行 Docker 19.03.12。当我在服务器上记录日期时,我得到了正确的时间

root@rtws-backend:~# date
Thu Mar 11 16:28:45 CET 2021

进入服务器上的nodejs时,时间比实际时间晚一小时

root@rtws-backend:~# node
Welcome to Node.js v15.3.0.
Type ".help" for more information.
> new Date()
2021-03-11T15:29:54.625Z

我的设置:

root@rtws-backend:~# timedatectl
Local time: Thu 2021-03-11 16:42:19 CET
Universal time: Thu 2021-03-11 15:42:19 UTC
RTC time: Thu 2021-03-11 15:42:20
Time zone: Europe/Zurich (CET, +0100)
System clock synchronized: yes
NTP service: n/a
RTC in local TZ: no

在 .env 文件中,TZ 设置为 Europe/Zurich

有任何想法吗?

4

0 回答 0