使用Google表格中的信息,在未来两周内制作Google日历活动

时间:2018-03-17 17:29:10

标签: google-apps-script google-sheets google-calendar-api

我想使用脚本将以活动工作簿标签命名的事件添加到我的日历中。该活动将在未来两周开始。我该怎么做?

我目前的代码:

function myFunction() {
  var name = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();

  var event = CalendarApp.getDefaultCalendar().createAllDayEvent('Check on status of re:'+name+' application',
     new Date('July 20, 1969')); //this should be two weeks from now
  Logger.log('Event ID: ' + event.getId());
}

1 个答案:

答案 0 :(得分:0)

function myFunction() {
var name = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();

  var date = new Date();
    var d = new Date(date.getTime()+14*3600000*24);



  var event = CalendarApp.getDefaultCalendar().createAllDayEvent('Check re:'+name+' application',
     d); //this should be two weeks from now

}