日期:2014-05-18 浏览次数:20429 次
var year = new Date().getFullYear(); var month = new Date().getMonth()+1; var day = new Date().getDay(); var hour = new Date().getHours(); var date = new Date().getDate(); switch(day) { case 0: day="日"; break; case 1: day="一"; break; case 2: day="二"; break; case 3: day="三"; break; case 4: day="四"; break; case 5: day="五"; break; case 6: day="六"; break; } var greetings = ""; if(hour>=6 && hour <=12) greetings += "早上好"; else if(hour >12 && hour <=19) greetings += "下午好"; greetings += "<br>今天是" + year+ "年"+month+"月"+date+"日"; greetings+="<br>星期"+day; document.write(greetings);
------解决方案--------------------
<script language="Javascript"> today=new Date(); function date(){ this.length=date.arguments.length for(var i=0;i<this.length;i++) this[i+1]=date.arguments } var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write( "<font color=##000000 style='font-size:9pt;font-family: 宋体'> ", today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日", d[today.getDay()+1],"</font>" ); </script>