最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Apps Script returns wrong timezone - Stack Overflow

programmeradmin2浏览0评论

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!

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!

Share Improve this question edited Jan 14, 2021 at 10:19 ale13 6,0823 gold badges11 silver badges26 bronze badges asked Jan 14, 2021 at 4:01 GenBreakerGenBreaker 515 bronze badges 20
  • Where's the code? – Cooper Commented Jan 14, 2021 at 4:16
  • 1 Did you know that your spreadsheet and script can have different timezones? – Cooper Commented Jan 14, 2021 at 4:17
  • minimal reproducible example.............. – Cooper Commented Jan 14, 2021 at 4:19
  • Yes I am aware, I have already checked the timezone of my spreadsheet file at spreadsheet settings. Even my google calendar, the timezone set is GMT+8(Taipei). Code: function date() { let = date = new Date(); Logger.log(date);} – GenBreaker Commented Jan 14, 2021 at 4:26
  • What's the timezone of the script project – Cooper Commented Jan 14, 2021 at 4:27
 |  Show 15 more ments

1 Answer 1

Reset to default 8

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.

发布评论

评论列表(0)

  1. 暂无评论