【问题标题】:Google Apps Script Time Based Trigger Date and HourGoogle Apps 脚本基于时间的触发日期和时间
【发布时间】:2015-05-26 03:04:53
【问题描述】:

我可以通过资源菜单手动添加时间驱动的触发器以在特定日期和时间运行,但我找不到如何以编程方式执行此操作。我有 .at(date) 方法,但我想为此添加一个特定时间。这可以通过编程方式实现吗?

文档中的示例:

 // Creates a trigger for December 1, 2012
 var triggerDay = new Date(2012, 11, 1);
 ScriptApp.newTrigger("myFunction")
   .timeBased()
   .at(triggerDay)
   .create();

“myFunction”能否在 2012 年 12 月 1 日早上 7 点运行?

感谢您的帮助。

【问题讨论】:

标签: google-apps-script triggers clock


【解决方案1】:

日期对象可以在其构造函数中取一个时间值。

var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);

触发器将从指定时间开始运行 +- 15 分钟。

【讨论】:

  • 谢谢!我以为我以前尝试过,但我认为我的语法不对。
猜你喜欢
  • 2020-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多