6

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

Andrey Shiryaev
  • 113
  • 1
  • 4

1 Answers1

5

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.

Capaj
  • 4,024
  • 2
  • 43
  • 56