【发布时间】:2017-06-22 01:36:08
【问题描述】:
脚本时间设置为 GMT 00
脚本接受用户的日期和时间
用户从日期时间字段设置本地日期时间
用户点击设置按钮
这将在 GMT 时间创建一个触发器,如何让它在本地时间触发?
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.createMenu('Custom Menu').addItem('Show sidebar', 'showSidebar').addToUi();
}
function showSidebar() {
var html = HtmlService.createHtmlOutputFromFile('Sidebar').setTitle('My custom sidebar').setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showSidebar(html);
}
function sendEmail() {
GmailApp.sendEmail(Session.getEffectiveUser().getEmail(), 'Reminder C Email', 'Reminding you about...');
}
function create(AT) {
SpreadsheetApp.getUi().alert(AT)
var at = moment(AT);
ScriptApp.newTrigger('sendEmail').timeBased().at(new Date(at)).inTimezone(getDefaultUserTimeZone()).create();
}
//script timezone is GMT 00
function getDefaultUserTimeZone() {
if (CalendarApp.getDefaultCalendar()) return CalendarApp.getDefaultCalendar().getTimeZone();
else return 'Etc/GMT';
}
【问题讨论】:
标签: javascript datetime google-apps-script datetimepicker