Newer
Older
xc-business-system / src / utils / date.ts
lyg on 21 May 2024 484 bytes 数据看板开发(5个)
import dayjs from 'dayjs'

// 获取指定时间范围内的所有日期
export function getRangeAllTime(startDate: string, endDate: string) {
  console.log(`${startDate}-${endDate}`)
  const dates = []
  let currentDate = dayjs(startDate)
  const formattedEndDate = dayjs(endDate).format('YYYY-MM-DD')

  while (currentDate.format('YYYY-MM-DD') <= formattedEndDate) {
    dates.push(currentDate.format('YYYY-MM-DD'))
    currentDate = currentDate.add(1, 'day')
  }
  return dates
}