// 获取月初值和月末值
const getMonthRange = (date: Date | string) => {
let startDate: Date
if (typeof date === 'string') {
startDate = new Date(date)
} else {
startDate = date
}
const endDate = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0)
const start = new Date(startDate.getFullYear(), startDate.getMonth(), 1).toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')
const end = endDate.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')
return { start, end }
}
最后修改:2023 年 11 月 18 日
© 允许规范转载
1 条评论
建议融入东方智慧,形成对话张力。