javascript - Google Apps Script returns wrong timezone - Stack Overflow

My google Apps Script script returned a wrong timezone with Date(). What I expect is GMT+8 (because I l

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745470452a4629108.html

相关推荐

  • javascript - Google Apps Script returns wrong timezone - Stack Overflow

    My google Apps Script script returned a wrong timezone with Date(). What I expect is GMT+8 (because I l

    1小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信