代码
function getWeekday(date) {
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const weekday = new Date(date).getDay();
return weekdays[weekday];
}
测试效果:
console.log("2023-12-27====", getWeekday('2023-12-27'))
console.log("2023-12-29====", getWeekday('2023-12-29'))