Google sheet spreadsheet have a time zone setting viewed via the File -> Settings menu. see image. However following code line
SpreadsheetApp.getActive().getSpreadsheetTimeZone();
returns: America/New_York
I'd like to get using app script the time zone string as it appears in the file setting ((GMT-5) Eastern Time) rathen than as it is returned by getSpreadsheetTimeZone()
. Is it possible?
CodePudding user response:
Use SimpleDateFormat
from Utilities.formatDate
:
const t_so70410789 = ()=>{
const t = SpreadsheetApp.getActive().getSpreadsheetTimeZone();
const f = Utilities.formatDate(new Date(),t,`'(GMT'XXX')' zzzz`)
console.log(f);
}