JavaScript/jQuery

【GAS】日付をフォーマットする方法!

あきぞらです。

今回は、GASで日付の値をフォーマットする方法を紹介していきます。

Utilities.formatDateを使う

Utilities.formatDateを使うことで、

日付の値をフォーマットすることができます。

// 本日の日付を取得
let today = new date();

// 日本時間で「yyyy/MM/dd」にフォーマット
today = Utilities.formatDate(today,”JST”, “yyyy/MM/dd”);

// 2021/01/06が出力される
consolog.(today)

日付の項目はよく使うので、覚えておくと便利です!

-JavaScript/jQuery

Copyright© あきぞらてっく , 2026 All Rights Reserved Powered by AFFINGER5.