Google Apps脚本返回错误的时区 [英] Google Apps Script returns wrong timezone

查看:44
本文介绍了Google Apps脚本返回错误的时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Google Apps脚本脚本返回了错误的时区,并带有 Date().我期望的是GMT + 8(因为我居住在亚洲),但是脚本时区返回GMT-5.甚至日志时间也不匹配.

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.

代码:

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

如何将其从GMT-5更改为GMT + 8?任何帮助将不胜感激!

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.

这可以通过以下方法完成:转到项目设置,然后勾选 Show"appsscript.json"清单文件在编辑器中.

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"
}

注意

请记住,您可以修改它并输入您选择的时区.

这篇关于Google Apps脚本返回错误的时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆