Is it just me or has something in Google changed recently? I have a function that adds a timestamp to edits that was working just fine, and just the other day it broke.
It broke in the sense that it used to stamp the time in my timezone - as is specified by the function formatting I use, Now it appears to be timestamping in GMT instead of GMT-8. Nothing has changed in my script, so what happened?
function happyFunTime() {
var s = SpreadsheetApp.getActiveSheet();
var r = s.getActiveCell();
var columnNum = r.getColumn();
var timeLastCalledColumnOffset = getTimeLastCalledColumnOffset();
var rowNum = r.getRow();
if (rowNum <=1) return;
timeLastCalledColumnOffset++;
// set dateCell = the current row at column J
var dateCell = s.getRange(rowNum, timeLastCalledColumnOffset);
var tZone= "GMT-8";
// Format the current date into datetime format
var dateTime = Utilities.formatDate(new Date(), tZone, "MMM-dd-yyyy h:mm a");
// Set the cell value. Add apostrophe to force text treatment & keep the spreadsheet from reformatting
dateCell.setValue("'" + dateTime);
}
getTimeLastCalledColumnOffset()
is a custom function to return a number of the column that contains the value I'm interested in (J, so 9 in this case).