提交表单时,我正在尝试获取带有简单格式日期的电子表格,但是所有日期(包括时间戳)都被发布为“1969 年 12 月 31 日下午 2:00”......我做错了什么?任何帮助将不胜感激。
function formSubmitReply(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var row = sheet.getActiveRange().getRowIndex();
var lastRow = sheet.getLastRow();
// Set the status of a new ticket to 'New'.
sheet.getRange(lastRow, getColIndexByName("Status")).setValue("New");
var ticketTime = sheet.getRange(row, getColIndexByName("Timestamp")).getValue();
var subdate = Utilities.formatDate(new Date(ticketTime), "GMT-10", "EEE MM/dd/yyyy 'at' h:mm a");
sheet.getRange(lastRow, getColIndexByName("Timestamp")).setValue(subdate);
var sDate = sheet.getRange(row, getColIndexByName("Start Date")).getValue();
var strtdate = Utilities.formatDate(new Date(sDate), "GMT-10", "EEE, MMM dd, yyyy");
sheet.getRange(lastRow, getColIndexByName("Start Date")).setValue(strtdate);
var sTime = sheet.getRange(row, getColIndexByName("Start Time")).getValue();
var strttime = Utilities.formatDate(new Date(sTime), "GMT-10", "h:mm");
//sheet.getRange(lastRow, getColIndexByName("Start Time")).setValue(strttime);
var eDate = sheet.getRange(row, getColIndexByName("End Date")).getValue();
var enddate = Utilities.formatDate(new Date(eDate), "GMT-10", "EEE, MMM dd, yyyy");
sheet.getRange(lastRow, getColIndexByName("End Date")).setValue(enddate);
var eTime = sheet.getRange(row, getColIndexByName("End Time")).getValue();
var endtime = Utilities.formatDate(new Date(eTime), "GMT-10", "h:mm");
//sheet.getRange(lastRow, getColIndexByName("End Time")).setValue(endtime);
}