思路:每个月的月末不一定,但是每个月的月初一定是 1 号,当前日期加 1 日,如果是 1 号就是月末
export const isLastDateOfCurrentMonth = (dateData: Date) => {
if (!dateData) return false;
const date: Date = new Date(dateData);
const next_date = new Date(date?.getTime() + 24 * 60 * 60 * 1000)?.getDate();
if (next_date === 1) {
return true;
}
return false;
};
其他: 获取当前日期的前几天,或后几天
const currentDate = new Date();
const oneDay = 24 * 60 * 60 * 1000;
const lastDate = new Date(currentDate?.getTime() - oneDay);
const nextDate = new Date(currentDate?.getTime() + oneDay);