~~~
window.onload=function(){
setInterval(function(){
var date=new Date();
var year=date.getFullYear(); //獲取當前年份
var mon=date.getMonth()+1; //獲取當前月份
var da=date.getDate(); //獲取當前日
var days=['日','一','二','三','四','五','六'];
var day=days[date.getDay()]; //獲取當前星期幾
var h=date.getHours(); //獲取小時
var m=date.getMinutes(); //獲取分鐘
var s=date.getSeconds(); //獲取秒
var hi=document.getElementById('NowHi');
var his="!";
if(h>5 && h<12){
his="早上好,一日之計在于晨!";
}else if(h>=12 && h<=13){
his="中午好,休息休息,吃午飯啦!";
}else if(h>13 && h<=18){
his="下午好,工作工作!";
}else if(h>18 && h<=22){
his="晚上好,休息休息,加班正常!";
}else if(h>22 && h<=23){
his="午夜好,準備睡覺吧!";
}else{
his="凌晨好,是時候關閉電腦了!";
}
hi.innerHTML=his;
var d=document.getElementById('NowDate');
d.innerHTML=year+'年'+mon+'月'+da+'日'+'星期'+day+' '+padNumber(h,2)+':'+padNumber(m,2)+':'+padNumber(s,2);
},1000)
}
~~~