JS根据日期得出星期几

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

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

return week;

}

 

例如:

1、获取系统时间并得出星期

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

2、根据给定例如

var da = '2017-12-12';

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

上一篇:msyql-week-1


下一篇:展示星期+日期的组件(自己封装一下)