😽

GASの時間表記(フォーマット)まとめ

2021/06/01に公開
function myFunction() {

let today = new Date();

// 2021/06/01 9:09:09
yyyymmddHHmmss = Utilities.formatDate(today, "JST", "yyyy/MM/dd HH:mm:ss");

// 2021/06/01
yyyymmdd = Utilities.formatDate(today,"JST", "yyyy/MM/dd");

// 06/01
mmdd = Utilities.formatDate(today,"JST", "MM/dd");

// 06/01
mmdd = Utilities.formatDate(today,"JST", "MM/dd");

// 曜日取得
let day = today.getDay();
let arrayDay = ['日', '月', '火', '水', '木', '金', '土']
let strDay = arrayDay[day]

}

セルから値を取得してフォーマットすることも可能


Utilities.formatDate(new Date(sheet.getRange(i,2).getValues()),"JST","MM/dd HH:mm")

Discussion