TriggerShelf

Error fix

Fix wrong time zone in Apps Script timestamps

Trigger: AnyServices: Utilities, SpreadsheetAppMock-tested: Nov 2026

apps script timezone wrong

Format timestamps with Utilities.formatDate and the spreadsheet time zone, so the text written to the cell does not depend on the script's zone.

Set it up

  1. Set File > Settings > Time zone in the sheet.
  2. Set the same zone in Project Settings (Show appsscript.json manifest file).
  3. Use stampNow to write text timestamps.

The script

/**
 * Fix: timestamps show the wrong time.
 * Format dates with an explicit time zone instead of relying on the default string.
 * Also set the zone in Project Settings (appsscript.json "timeZone").
 */
function stampNow(sheet, row, col) {
  var tz = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone();
  var text = Utilities.formatDate(new Date(), tz, 'yyyy-MM-dd HH:mm:ss');
  sheet.getRange(row, col).setValue(text);
  return text;
}
Test status. 2 of 2 automated checks pass, run Nov 2026 against simulated Google services. This recipe has not yet been run inside a live Google account. Test it on a copy of your sheet first.

What you should see

Written value
2026-11-14 10:02:31

Same moment, formatted in the sheet zone. Sample values, not output from a real account.

Common errors and fixes

The sheet and script show different times
They have separate time zone settings. Set both.
Dates become text
stampNow writes text. Write new Date() instead when you need a real date cell.

Permissions. Running this script asks you to grant Google permissions for the services listed above, to your own script. TriggerShelf never receives your Google data. See the permissions table. Google will show "Google hasn't verified this app"; that is expected for a script you paste yourself.