在特定日期和时间运行触发器 [英] Run trigger at specific date and time

查看:158
本文介绍了在特定日期和时间运行触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在特定的日期和时间(+或-15分钟)运行触发器。

I want to run a trigger at specific date and time (+or - 15 min).

我有一个带有YYYY-MM-DD HH的日期最小值字符串:MM格式说 2017-04-01 18:05 我将如何修改以下脚本以在18小时5分钟运行。

I have a date min string with YYYY-MM-DD HH:MM format say 2017-04-01 18:05 How will I modify the below script to run at 18 hours and 5 minutes.

 var triggerDay = new Date(2017, 04, 01);
 ScriptApp.newTrigger("myFunction")
   .timeBased()
   .at(triggerDay)
   .create();


推荐答案

您可以尝试以下方法:

function createTimeDrivenTriggers() {
// Trigger on 2017-04-01 around 18:00 (±15 min).
ScriptApp.newTrigger('myFunction')
    .timeBased()
    .atDate(2017, 04, 01)
    .atHour(18)
    .create();
}

https://developers.google.com/apps-script/reference/script/clock-trigger-builder

这篇关于在特定日期和时间运行触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆