%
d=Date()
t=Time()
%>
var t0=new Date().getTime();
var nyear=%=Year(d)%>;
var nmonth=%=Month(d)%>;
var nday=%=Day(d)%>;
var nwday=%=WeekDay(d)%>-1;
var nhrs=%=Hour(t)%>;
var nmin=%=Minute(t)%>;
var nsec=%=Second(t)%>;
//獲得本機時間和服務(wù)器時間之差
var dectime=new Date(nyear,nmonth-1,nday,nhrs,nmin,nsec).getTime()-t0;
nday=-1;
//用于顯示時間的span
document.write("span id=\"clock\" style=\"word-break:keep-all\">/span>");
//時間計算函數(shù):
function NewTick(){
var noww=new Date();
var t1=noww.getTime();
noww.setTime(t1+dectime);
if(noww.getDate()!=nday){
nyear=noww.getFullYear();nmonth=noww.getMonth()+1;nwday=noww.getDay();nday=noww.getDate();
}
nhrs=noww.getHours();nmin=noww.getMinutes();nsec=noww.getSeconds();
}
//時間顯示函數(shù):
function Draw(){
NewTick(); //先計算
var s=nyear+'年'+nmonth+'月'+nday+'日 '+'星期'+cweekday(nwday)+' '+shapetime(nhrs,nmin,nsec);
s+=" 農(nóng)歷"+lmonth+"月"+lday;//顯示農(nóng)歷
document.getElementById("clock").innerHTML=s;
//每隔500毫秒重新獲取一下本機時間:
setTimeout("Draw()",500);
}
//開始顯示:
Draw();