I'm looking for a way to set up a one-time trigger for a function within a Google Apps Script. Essentially, I want to schedule an event to occur at a specific date and time in the future, without it being a recurring event.
However, every time I try to do this, I keep encountering an error message that says: "Exception: You cannot schedule an event in the past." Any insights or assistance on how to resolve this issue would be greatly appreciated.
function trigger(){
var rawdate = "2020-07-29T11:30";
var time = rawdate.substr(11).split(':');
var durationMilliseconds = time[0] * 3600000 + time[1] * 60000;
var year = rawdate.substr(0,4);
var month = rawdate.substr(5,2);
var date = rawdate.substr(8,2);
ScriptApp.newTrigger("myFunction")
.timeBased()
.atDate(year, month, date)
.after(durationMilliseconds)
.inTimezone("America/New_York")
.create();
}