use*_*545 5 javascript google-apps-script
我有一个存储在数组中的函数,并从文档循环数据.在这个内部,有一些日期格式为dd/mm/yyyy的单元格...但是当我通过电子邮件发送时,看起来像Wed Jan 01 2014 00:00:00 GMT-0300(ART)
我在这个函数里面使用了一个formatDate方法但是通过我一个错误 找不到方法formatDate(string,string,string). 我如何才能获得正确的格式化日期?
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;
}
Run Code Online (Sandbox Code Playgroud)
Ami*_*wal 12
在调用formatDate()方法之前,您需要先将字符串转换为日期.
temp = new Date(usersExpDate[n]);
temp = Utilities.formatDate(temp, "GMT", "yyyy-MM-dd");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7421 次 |
| 最近记录: |