这是我的脚本,我正在尝试删除格式为00/00/0000的标签 它将从昨天的日期删除标签。但是它一直在删除1月和11月1/01/19和11/01/19的标签。我不知道为什么吗?
var now = new Date();
var dayInMonth = now.getDate() - 1;
var monthInYear = now.getMonth() + 1;
var year = now.getYear().toString().substr(-2);
var todaysDate = monthInYear + '/' + dayInMonth + '/' + year;
function main() {
var labSel = AdWordsApp.labels()
.withCondition("Name CONTAINS 'End Date'")
.get();
while(labSel.hasNext()) {
var thisLab = labSel.next();
var thisLabName = thisLab.getName();
var labDate = thisLabName.substring(10);
if(todaysDate === labDate) {
thisLab.remove();
Logger.log("Label '" + thisLabName + "' passed, Label Removed");
}
}
}