Skip to main content

Acquisition of Japan Standard Time

This section describes how to get a time zone from a specific spreadsheet.

function to use

Spreadsheet.getSpreadsheetTimeZone();

Use getSpreadsheetTimeZone() provided in the Spreadsheet class.

The return value is returned by the string.You can check the available time zone in Joda.org

You may need to authenticate at the first execution because you will access the spreadsheet when execution.

Sample code

/**
* Eligible spreadsheet ID
* https://docs.google.com/spreadsheets/d/〇〇〇/edit Part of the 〇〇〇
*/
const SPREAD_SHEET_ID = '_______________';

/**
* Return 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 execute, the spreadsheet time zone is returned.

In Japan, you can get "Asia/Tokyo".