Skip to content

Get the time zone

This article explains how to get the time zone of a specific spreadsheet.

Spreadsheet.getSpreadsheetTimeZone();

Use getSpreadsheetTimeZone(), which is provided by the Spreadsheet class.

The return value is a time zone ID string in “Area/City” format, such as "America/New_York". You can find the available time zones on Joda.org.

Because the script accesses the spreadsheet, you may need to authorize it the first time you run it.

/**
* ID of the target spreadsheet
* The xxx part of https://docs.google.com/spreadsheets/d/xxx/edit
*/
const SPREAD_SHEET_ID = '_______________';
/**
* Returns the time zone of the spreadsheet
*/
const getSheetTimeZone = () => {
/** Target spreadsheet */
const ss = SpreadsheetApp.openById(SPREAD_SHEET_ID);
/** Time zone */
const timeZone = ss.getSpreadsheetTimeZone();
console.log(timeZone);
return timeZone;
};

When you run it, the spreadsheet’s time zone is returned.

If the time zone is set to Japan Standard Time (“(GMT+09:00) Tokyo”), you get "Asia/Tokyo".