思路:每个月的月末不一定,但是每个月的月初一定是 1 号,当前日期加 1 日,如果是 1 号就是月末
/**
* 判断当前日期是否是该月的最后一天,即月末判断
* @param date
* @returns
*/
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);
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/64445.html