Google 表格電子表格有一個時區設定,可通過檔案 -> 設定選單查看。看圖片。
但是下面的代碼行
SpreadsheetApp.getActive().getSpreadsheetTimeZone();
回傳:美國/紐約
我想使用 app 腳本中的時區字串,因為它出現在檔案設定((GMT-5)東部時間)中,而不是由getSpreadsheetTimeZone(). 是否可以?
uj5u.com熱心網友回復:
使用SimpleDateFormat自Utilities.formatDate:
const t_so70410789 = ()=>{
const t = SpreadsheetApp.getActive().getSpreadsheetTimeZone();
const f = Utilities.formatDate(new Date(),t,`'(GMT'XXX')' zzzz`)
console.log(f);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/386118.html
標籤:javascript 日期 谷歌应用程序脚本 简单日期格式 时区偏移
上一篇:默認情況下使TextInputEditText成為焦點
下一篇:如何從給定日期獲取月份中的第幾周
