简体   繁体   English

应用程序脚本格式日期的时间错误

[英]Apps script formatDate has wrong time

在此处输入图像描述

I'm working with apps script.我正在使用应用程序脚本。 In my code I have:在我的代码中,我有:

var date =Utilities.formatDate(new Date(), "EST", "yyyy-MM-dd HH:mm:ss");
var now = Date.now();

I'm in the eastern time zone.我在东部时区。 I ran the function containing the lines above 1 minute ago.我在 1 分钟前运行了包含上述行的 function。 As you can see in the screenshot in the lower right corner the actual time and the time in the editor differ by an hour.正如您在右下角的屏幕截图中看到的那样,实际时间和编辑器中的时间相差一个小时。 What am I doing wrong?我究竟做错了什么?

As mentioned by Cooper, you probably have a wrong time zone.正如 Cooper 所说,您可能有错误的时区。 Take a look in your project properties.查看您的项目属性。 Try checking the time zone in your spreadsheet too.尝试检查电子表格中的时区。

在此处输入图像描述

If that doesn't work, try also changing project time zone to a different one and changing it back to your correct time zone.如果这不起作用,请尝试将项目时区更改为其他时区并将其更改回正确的时区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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