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

 

posted @ 2022-08-11 17:17  大da脸  阅读(370)  评论(0编辑  收藏  举报