// 从数组中删除今天之前的日期以及指定的日期
function removePastDates(datesArray, specifiedDates) {
// 获取今天的日期
var today = new Date();
today.setHours(0, 0, 0, 0); // 设置时间为当天的午夜 00:00:00
// 创建一个新数组来存储保留的日期
var filteredDates = [];
// 迭代数组中的每个日期
datesArray.forEach(function(dateString) {
// 将日期字符串转换为 Date 对象
var date = new Date(dateString);
// 检查日期是否在今天之后,并且不在指定的日期数组中
if (date >= today && !specifiedDates.includes(dateString)) {
// 将日期添加到新数组中
filteredDates.push(dateString);
}
});
console.log(filteredDates)
return filteredDates;
}
js 从数组剔除今天之前的日期 及指定的日期
最新推荐文章于 2024-05-31 10:26:40 发布