星期天显示不对 我像上面评论说的那样修改了
function setTime() { var nowdate = new Date(); //获取年月日时分秒 var year = nowdate.getFullYear(), month = nowdate.getMonth() + 1, day = nowdate.getDate(), hours = nowdate.getHours(), minutes = nowdate.getMinutes(), seconds = nowdate.getSeconds(), date = nowdate.getDate(); //var weekday =["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]; var weekday = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); // 获取日期id date_info.innerHTML = year + "年" + month + "月" + day + "日 " + weekday[day % 7]; hour_time.innerHTML = hours >= 10 ? hours : "0" + hours; minute_time.innerHTML = minutes >= 10 ? minutes : "0" + minutes; second_time.innerHTML = seconds >= 10 ? seconds : "0" + seconds; console.log(year + "年" + month + "月" + day + "日 " + weekday[day % 7]); //时分秒针设置
然而现实的是 7月16号 星期二 实际的是星期四