Google 应用脚本中的函数 Utilities.formatDate
对于 2013 年的日期无法正常工作
示例-
date = Tue Dec 31 2013 18:43:12 GMT+0530 (IST)
after formatting it in YYYYMMdd format
使用代码-
Utilities.formatDate(date, "IST" ,"YYYYMMdd"))
result was- 20**14**1231
根据上述日期,上述结果年份预计为 2013 年。
相同的代码在 2012 年和 2014 年的日期中工作正常。
最佳答案
只需将您的模式从 YYYY 更改为 yyyy(小写)即可,请检查 this :
function myFunction() {
var date = new Date("Tue Dec 31 2013 18:43:12 GMT+0530 (IST)");
//after formatting it in YYYYMMdd format
var format = Utilities.formatDate(date,"IST", "yyyyMMdd");
Logger.log(format);
}
关于google-apps-script - Google App Scripts 中的实用程序功能无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20884766/