var s ="";
switch((new Date()).getDay()){
case 0: s = "星期日";break;
case 1: s = "星期一";break;
case 2: s = "星期二";break;
case 3: s = "星期三";break;
case 4: s = "星期四";break;
case 5: s = "星期五";break;
case 6: s = "星期六";break;
}
alert(s);
或者这样:
var day = time.getDay();
var weekDesc = new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六");
for(var i=0;i<weekDesc.length;i++){
if(day==i){
document.getElementById("time").innerHTML="今天是:"+weekDesc[i];
}
}
又或者这样
var weekDay = "日一二三四五六".split("")[new Date().getDay()];
alert(weekDay);
反正就是一个思路。
Comments (暂无评论)