0
使用Google Apps腳本,我可以獲取上個月的第一個和最後一個日期,然後將格式更改爲GMT'yyyy-MM-dd'如何使用Google Apps腳本獲取上月的日期格式
var todayDate = new Date();
var lastDate = function getLastDate() {
var d = todayDate;
d.setDate(0);
return Utilities.formatDate(d, 'GMT', 'yyyy-MM-dd');
}
var firstDate = function getFirstDate() {
var e = todayDate;
e.setMonth(e.getMonth() - 1);
e.setDate(1);
return Utilities.formatDate(e, 'GMT', 'yyyy-MM-dd');
}
但是我得到一個錯誤,指出:
「值無效」功能getLastDate(){風險d = todayDate; d.setDate(0);返回Utilities.formatDate(例如, 「GMT」 ,「yyyy-MM-dd」);}'。值必須匹配以下正則表達式:'[0-9] {4} - [0-9] {2} - [0-9] {2} |今天|昨天| [0-9] +(daysAgo)'「
有人可以幫忙嗎?
想要使用Logger.log嗎? – enano2054