How set default timezone in node js for windows

社会主义新天地 提交于 2019-12-12 18:19:17

问题


I'm trying to set the time zone at the start of the application

set "TZ=UTC"
node main.js

But is not work:

// main.js

var tz = process.env.TZ;
var date = new Date();
console.log(tz, '||', date);

UTC Tue Nov 17 2015 21:41:29 GMT+0300


回答1:


I published a small utility called set-tz which takes advantage of tzutil CLI command. When you call setTZ() it effectively changes your PC's timezone so beware-if you kill the process, you'll need to manually revert back after you're done-I am assuming you'r process is short-lived. If you don't kill your process, it will revert your original timezone back for you.



来源:https://stackoverflow.com/questions/33764725/how-set-default-timezone-in-node-js-for-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!