// 计算指定时间是星期几
function getweekday(date){
// date例如:'2022-03-05'
var weekArray = new Array("星期日","星期一", "星期二", "星期三", "星期四", "星期五", "星期六")
var week = weekArray[new Date(date).getDay()]
return week
}
使用:
getweekday('2022-03-05') // '星期六'
// 计算指定时间是星期几
function getweekday(date){
// date例如:'2022-03-05'
var weekArray = new Array("星期日","星期一", "星期二", "星期三", "星期四", "星期五", "星期六")
var week = weekArray[new Date(date).getDay()]
return week
}
使用:
getweekday('2022-03-05') // '星期六'