js格式化星期

js格式化星期几

完整代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
var dates = new Date();
Date.prototype.getWeek=function(fmt){
var xinq = this.getDay();
var xinqArray = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
var strWeek;
for(var weeki=0;weeki<xinqArray.length;weeki++){
strWeek = xinqArray[xinq];
}
return strWeek;
};
var day = dates.getWeek();

console.log("星期几:"+day)
</script>
</body>
</html>

结果:

星期几:星期四


六月初字帖坊小程序 你想要的字帖模板及工具,这里都有!