运行代码时,我收到错误消息(如下)。我的目的是在准确的时间创建一个触发器2017-04-03 20:10
ScriptApp.newTrigger('myfunction').timeBased().atDate(2017,04,03).atHour(20).nearMinute(10).create();
日志
[17-04-02 20:16:53:455 IST] TriggerBuilder.timeBased() [0 seconds]
[17-04-02 20:16:53:456 IST] ClockTriggerBuilder.atDate([2017, 4, 3]) [0 seconds]
[17-04-02 20:16:53:456 IST] ClockTriggerBuilder.atHour([20]) [0 seconds]
[17-04-02 20:16:53:461 IST] Execution failed: Error: Already chosen a specific date time with at() or atDate(). (line 109, file "Code") [11.583 seconds total runtime]
答案 0 :(得分:2)
您可以创建具有特定日期和时间的新日期对象,然后使用新的trigger().At(date),不要与atDate()混淆,在该日期和时间创建触发器。
var dt = new Date(2017,03,03,20,10)
//Month index starts from 0 i.e. Jan =0,Feb=1... So on
ScriptApp.newTrigger('myFunction').timeBased().at(dt).create()
希望有所帮助!