function reminder() {
var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var data = sh.getDataRange().getValues()
var d = new Date().getTime();
for (var i=1;i<data.length;i ){
if (data[i][4]<=new Date(d 7*24*60*60*1000) && data[i][4]>=new Date(d 5*24*60*60*1000) && data[i][6]==''){
MailApp.sendEmail({to:data[i][3],
subject: 'Reminder Process Update Required in 1 week',
htmlBody: 'Hello ' data[i][1] ' The page for ' data[i][0] ' is due to review on ' data[i][4] ' Please review the content and contact the team before its due date if amendments are required.'
})
sh.getRange(i 1,7).setValue('sent')
}
else if (data[i][4]<=new Date(d 30*24*60*60*1000) && data[i][4]>=new Date(d 28*24*60*60*1000) && data[i][5]==''){
MailApp.sendEmail({to:data[i][3],
subject: 'Reminder Process Update Required in 1 month',
htmlBody: 'Hello ' data[i][1] ' The page for ' data[i][0] ' is due to review on ' data[i][4] ' Please review the content and contact the team before its due date if amendments are required.'
})
sh.getRange(i 1,6).setValue('sent')
}
}
}
如何更改腳本中的日期格式,它當前正在生成自動電子郵件,但是日期正在格式化并顯示時間以及(東部標準時間)我希望它只顯示不包含時間的日期。
uj5u.com熱心網友回復:
在需要格式化日期的地方呼叫此函式。
function formatDate(date) {
var d = new Date(date),
month = '' (d.getMonth() 1),
day = '' d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' month;
if (day.length < 2)
day = '0' day;
return [ day, month, year].join('/');
}
uj5u.com熱心網友回復:
您可以創建一個格式功能,如
function formatDate(d) {
return `${String(d.getDate()).padStart(2, '0')}/${String(d.getMonth() 1).padStart(2, '0')}/${d.getFullYear()}`;
}
例子:
function formatDate(d) {
return `${String(d.getDate()).padStart(2, '0')}/${String(d.getMonth() 1).padStart(2, '0')}/${d.getFullYear()}`;
}
const i = 0;
const data = [['Client', 'Recipient',,, new Date()]];
console.log('Hello ' data[i][1] ' The page for ' data[i][0] ' is due to review on ' formatDate(data[i][4]) ' Please review the content and contact the team before its due date if amendments are required.');
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/377816.html
上一篇:物件串列到HTML無序串列
