js获取今天是周几

function getMyDay(date){
var week;
if(date.getDay()==0) week="周日"
if(date.getDay()==1) week="周一"
if(date.getDay()==2) week="周二"
if(date.getDay()==3) week="周三"
if(date.getDay()==4) week="周四"
if(date.getDay()==5) week="周五"
if(date.getDay()==6) week="周六"
return week;
}

var w1 = getMyDay(new Date("2015-7-12"));


//指定的时间判断是周几
new Date('2019-08-27').getDay()---》得到2,表示周二

如果想要获取到今天是周几,则 
new Date().getDay()---》获取到今天是周几

 

你可能感兴趣的:(js)