nodejs时间默认显示为UTC格式导致用户误以为blockchain-explorer时间错误

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 #

说明:nodejs旧版本(5.3.0)支持通过设置TZ环境变量,切换时区。但是blockchain-explorer所用nodejs版本较新不支持该操作!

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

docker容器时区设置

区块细节

改进建议:建议对nodejs比较熟悉的小伙伴,修改blockchain-explorer源码。若其它小伙伴有更好地办法,不用修改源码的话,烦请留言告知下。

猜你喜欢

转载自blog.csdn.net/ory001/article/details/108518957
今日推荐