除了时间戳发生时它比我的实际时间晚 2 小时外,一切都适用于我的代码。我如何让它知道 CST 时区,还是 Google 表格中需要更改的内容?这是我第一次使用代码,我很惊讶我能走到这一步。
function onEdit(e) {
var sh = e.source.getActiveSheet();
var sheets = ['TK Assignments']; // Which sheets to run the code.
// Columns with the data to be tracked. 1 = A, 2 = B...
var ind = [15, 17, 19].indexOf(e.range.columnStart);
// Which columns to have the timestamp, related to the data cells.
// Data in 1 (A) will have the timestamp in 4 (D)
var stampCols = [16, 18, 20]
if(sheets.indexOf(sh.getName()) == -1 || ind == -1) return;
// Insert/Update the timestamp.
var timestampCell = sh.getRange(e.range.rowStart, stampCols[ind]);
timestampCell.setValue(typeof e.value == 'object' ? null : new Date());