GAS 当月年月日、前月年月日の取得

google
// 当月  
var date = new Date(); 
var currentYear = Utilities.formatDate(date, 'JST', 'yyyy');
var currentMonth = Utilities.formatDate(date, 'JST', 'MM');
var currnetYmd = Utilities.formatDate(date, 'JST', 'yyyyMMdd');

// 前月*
date.setMonth(date.getMonth() - 1);

var prevYear = Utilities.formatDate(date, 'JST', 'yyyy');
var prevMonth = Utilities.formatDate(date, 'JST', 'MM');
var prevYmd = Utilities.formatDate(date, 'JST', 'yyyyMMdd');

関連記事一覧

NEW