Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
180 views
in Technique[技术] by (71.8m points)

javascript - Google Apps Script returns wrong timezone

My google Apps Script script returned a wrong timezone with Date(). What I expect is GMT+8 (because I live in Asia) but the script timezone returns GMT-5. Even the log time is not match.

Code:

let date = new Date(); 
Logger.log(date);

enter image description here How can I change it from GMT-5 to GMT+8? Any help would be highly appreciated!

enter image description here

question from:https://stackoverflow.com/questions/65713259/google-apps-script-returns-wrong-timezone

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can change the timezone of your script by modifying the manifest file.

This can be done by going to Project Settings and ticking the Show "appsscript.json" manifest file in editor.

enter image description here

Afterwards, just update the manifest file to this:

{
  "timeZone": "Asia/Taipei",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"
}

Note

Please bear in mind that you can modify this and input the timezone of your choice.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...