// 获取指定月份的最后一天
lastDayOfMonth(date = new Date()) {
const year = date.getFullYear();
const month = date.getMonth() + 1; // 月份从0开始计算,需要加1
const lastDay = new Date(year, month, 0).getDate();
return lastDay;
},
// 根据季度获取季度第一天和最后一天
getQuarterStartEndDates(year, quarter) {
const startMonth = (quarter - 1) * 3 + 1;
const endMonth = startMonth + 2;
const startDate = new Date(year, startMonth - 1, 1);
const endDate = new Date(year, endMonth, 0);
return {
start: moment(startDate).format('YYYY-MM-DD'),
end: moment(endDate).format('YYYY-MM-DD'),
};
},
// 判断第几季度
judementQuarter() {
const currentMonth = new Date().getMonth() + 1;
const currentQuarter =
currentMonth <= 3 ? 1 : currentMonth <= 6 ? 2 : currentMonth <= 9 ? 3 : 4;
return currentQuarter;
},
04-02
395
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-25
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-01
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交