[英]Avoid formatDate error in Google Apps Script
ive got a function to storage in an array and loop data from a document.我得到了一个 function 来存储在数组中并从文档中循环数据。 Inside this one, there are cells with dates in format dd/mm/yyyy...but when I send it by email, appears like Wed Jan 01 2014 00:00:00 GMT-0300 (ART)
在这个里面,有日期格式为 dd/mm/yyyy 的单元格......但是当我通过 email 发送它时,看起来像Wed Jan 01 2014 00:00:00 GMT-0300 (ART)
I used inside this function, a formatDate method but through me an error Cannot find method formatDate(string,string,string).我在这个 function 里面使用了一个 formatDate 方法,但是通过我一个错误找不到方法 formatDate(string,string,string)。 How I can get the right formated date?
如何获得正确的格式化日期?
function getUsersExpDate(usersExpDate) {
var expDateArray = [];
var temp = usersExpDate[0];
for(var n=0; n < usersExpDate.length; n++){
expDateArray.push( usersExpDate[n] );
temp = usersExpDate[n];
temp = Utilities.formatDate(temp, "GMT", "yyyy-MM-dd");
}
return expDateArray;
}
You need to convert the string to date first before calling the formatDate() method.在调用 formatDate() 方法之前,您需要先将字符串转换为日期。
temp = new Date(usersExpDate[n]);
temp = Utilities.formatDate(temp, "GMT", "yyyy-MM-dd");
@Amit sir - Awesome.;. @Amit 先生 - 太棒了。;。 It worked sirji, I have had the same issue and NO ONE HELPED.
它有效,sirji,我遇到了同样的问题,没有人帮助。 I have been learning javascript and it was really TOUGH for me to identify the issue and find a solution.
我一直在学习 javascript,发现问题并找到解决方案对我来说真的很困难。 So had been searching for a solution for this issue form past one week and had given up.
所以过去一周一直在寻找这个问题的解决方案并放弃了。 was such a disappointment.
真是令人失望。 until I found your solution and BINGO.
直到我找到你的解决方案和宾果游戏。 It worked...
有效...
For few this issue might be nothing, but I know the trauma I had been through and finding a solution for he issue was really important for me..I hope everyone can understand...Wish to treat you sir ji...对于少数人来说,这个问题可能无关紧要,但我知道我所经历的创伤并为他的问题找到解决方案对我来说真的很重要..我希望每个人都能理解......希望对你先生 ji...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.