Skip to content

Instantly share code, notes, and snippets.

@linglung
Forked from mhawksey/gist:3518867
Created November 4, 2019 16:56
Show Gist options
  • Save linglung/3a019876932712988b8526eaa88b2878 to your computer and use it in GitHub Desktop.
Save linglung/3a019876932712988b8526eaa88b2878 to your computer and use it in GitHub Desktop.
Google Apps Script snippet to run time based triggers during specified periods
function scheduledCollection(){
var schedule = [];
// dates/times in mm/dd/yyyy hh:mm - timezone matches settings in File > Project properties
schedule.push({start:"08/29/2012 15:00", end:"08/29/2012 16:00"});
schedule.push({start:"08/29/2012 20:00", end:"08/29/2012 22:00"});
checkCollect(schedule);
}
function checkCollect(schedule){
var now = new Date();
for (i in schedule){
var start = new Date(schedule[i].start);
var end = new Date(schedule[i].end);
if (now > start && now < end){
// insert function you want to run here
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment