Utilities.formatDate日期未设置正确 [英] Utilities.formatDate Date not set correct

查看:168
本文介绍了Utilities.formatDate日期未设置正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储日期如下:

  existingDate = Wed Apr 30 2014 00:00:00 GMT + 0100( BST)

当我使用 Utilities.formatDate 以格式化日期更改为前一天的日期。

  var formattedDate = Utilities.formatDate(new Date(existingDate), GMT,dd / MM / yyyy); 

然后将格式化的日期设置为 29/04/2014 不是 30/04/2014



是否有其他人看到这种行为。

解决方案

Utilities.formatDate 似乎工作正常。 您在 GMT-1 中有4月30日午夜,但您可以告诉它在不同的时区格式化此日期 GMT ,或更多的明确GMT-0。预期的结果确实是4月29日23h。



Utilities.formatDate 必须是您想要的时区。


I have a date stored as follows:

existingDate = Wed Apr 30 2014 00:00:00 GMT+0100 (BST)

When I use Utilities.formatDate to format the date the date is changed to the day before.

var formattedDate = Utilities.formatDate(new Date(existingDate), "GMT", "dd/MM/yyyy");

the formatted date is then set to 29/04/2014 and not 30/04/2014.

Has anyone else seen this behavior.

解决方案

Utilities.formatDate seems to be working fine.

You have Apr 30 midnight in GMT-1 but then you tell it to format this date in a different timezone GMT, or more explicity GMT-0. The expected result is indeed Apr 29 23h.

The second parameter in Utilities.formatDate must be the timezone you desire.

这篇关于Utilities.formatDate日期未设置正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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