<html>
<head>
<title>ceshi</title>
</head>
<body><div id="header">
<script type="text/javascript">
now = new Date(),
hour = now.getHours()
if(hour < 6){document.write("尊敬的用户:您来的可真早!")}
else if (hour < 8){document.write("尊敬的用户:新的一天开始啦!")}
else if (hour < 12){document.write("尊敬的用户:上午好!")}
else if (hour < 14){document.write("尊敬的用户:中午好!")}
else if (hour < 18){document.write("尊敬的用户:下午好!")}
else if (hour < 22){document.write("尊敬的用户:晚上好!")}
else if (hour < 24){document.write("尊敬的用户:夜深了,早点休息吧!")}
</script>
【今天是
<script type="text/javascript">
today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
document.write(
"<font style='font-size:9pt;font-family: 宋体'> ",
today.getFullYear(),"-",
today.getMonth()+1,"-",
today.getDate(),"",
" ",
d[today.getDay()+1],
"</font>" );
</script>
】
</div></body>
</html>
参考资料:http://www.cnblogs.com/52net/archive/2013/04/26/3044664.html