JS gets the day of the week based on the date

function getweekday(date){
    
    
var weekArray = new Array("日", "一", "二", "三", "四", "五", "六");

var week = weekArray[new Date(date).getDay()];//注意此处必须是先new一个Date

return week;

}

 

For example:

1. Get the system time and get the day of the week

var week = weekArray[new Date().getDay()];

2. According to the given example

var da = '2017-12-12';

var week = weekArray[new Date(da).getDay()];//注意此处必须是先new一个Date

Guess you like

Origin blog.csdn.net/weixin_40362806/article/details/131050844