简体   繁体   中英

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);

在此处输入图像描述 How can I change it from GMT-5 to GMT+8? Any help would be highly appreciated!

在此处输入图像描述

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 .

在此处输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM