admin管理员组文章数量:1426943
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
1 Answer
Reset to default 8You 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.
本文标签: javascriptGoogle Apps Script returns wrong timezoneStack Overflow
版权声明:本文标题:javascript - Google Apps Script returns wrong timezone - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745470452a2659724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论