Nodejs time is displayed in UTC format by default, causing users to mistakenly think that blockchain-explorer time is wrong

docker exec -it explorer.mynetwork.com sh

/opt/explorer # date -R
Thu, 10 Sep 2020 17:15:49 +0800
/opt/explorer # node --version
v10.19.0
/opt/explorer # node
> new Date();
2020-09-10T09:15:58.785Z
> new Date().toLocaleString();
'9/10/2020, 5:16:45 PM'
> .exit
/opt/explorer #

Note: The old version of nodejs (5.3.0) supports switching the time zone by setting the TZ environment variable. But the newer version of nodejs used by blockchain-explorer does not support this operation!

> process.env.TZ = 'Asia/Shanghai';
> new Date();

Docker container time zone setting

Block details

Suggestions for improvement : It is recommended that friends who are familiar with nodejs modify the source code of blockchain-explorer. If other friends have a better way and don't need to modify the source code, please leave a message to let us know.

Guess you like

Origin blog.csdn.net/ory001/article/details/108518957
Recommended