dayjs로 특정 날짜가 포함된 주의 모든 날짜 가져오기 — week 는 로케일을 따르고 isoWeek 는 ISO 8601(월요일 시작)을 따른다.1

import dayjs from 'dayjs'
import isoWeek from 'dayjs/plugin/isoWeek'
dayjs.extend(isoWeek)

// startOf('week') → 로케일의 주 시작 (기본 en·ko 는 일요일, en-gb 는 월요일)
// startOf('isoWeek') → 월요일 시작 (캘린더 UI에 주로 사용)
function getWeekDays(date, iso = true) {
  const start = dayjs(date).startOf(iso ? 'isoWeek' : 'week')
  return Array.from({ length: 7 }, (_, i) =>
    start.add(i, 'day').format('YYYY-MM-DD')
  )
}

getWeekDays('2025-10-28') // ['2025-10-27', ..., '2025-11-02']

Footnotes

  1. StartOf - Day.js: week — “the first day of this week, 00:00 (locale aware)” / isoWeek — “the first day of this week according to ISO 8601, 00:00” ↩

`#513`