LoginSignup
2
2

More than 3 years have passed since last update.

【GASの3歩目】if文で曜日の処理をする

Last updated at Posted at 2019-07-29

formatDate(date, timeZone, format)

function isHoliday() {
  var week = Utilities.formatDate(new Date(), 'Asia/Tokyo', 'u');
  if (week == 7) {
    return true;
  }
}

formatDateメソッドの見方
Class SimpleDateFormat

  • u
    • Day number of week (1 = Monday, ..., 7 = Sunday)
    • 月[1]
    • 火[2]
    • 水[3]
    • 木[4]
    • 金[5]
    • 土[6]
    • 日[7]

week == 7
であればweekは日曜日をさすため、isHoliday関数はtrue

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2