Google Apps脚本基于时间的触发日期和时间 [英] Google Apps Script Time Based Trigger Date and Hour
本文介绍了Google Apps脚本基于时间的触发日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以添加一个时间驱动的触发器,以通过资源菜单手动在特定的日期和时间上运行,但是我找不到如何以编程方式进行操作.我有.at(date)方法,但是我想添加一个特定的时间.这可以通过编程实现吗?
I can add a time-driven trigger to run on a specific date and time manually via the resources menu, but I cannot find how to do it programatically. I have the .at(date) method, but to this I would like to add a specific time. Is that possible programatically?
文档中的示例:
// 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点运行?
Can "myFunction" be run on Decemeber 1, 2012 at 7 am?
谢谢您的帮助.
推荐答案
date对象可以在其构造函数中采用时间值.
The date object can take a time value in its constructor.
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
触发器将从指定时间开始+-15分钟.
The trigger will run +- 15 minutes from the specified time.
这篇关于Google Apps脚本基于时间的触发日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文