<%
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)%>;
//获得本机时间和服务器时间之差
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>");
//时间计算函数:
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();
}
//时间显示函数:
function Draw(){
NewTick(); //先计算
var s=nyear+'年'+nmonth+'月'+nday+'日 '+'星期'+cweekday(nwday)+' '+shapetime(nhrs,nmin,nsec);
s+=" 农历"+lmonth+"月"+lday;//显示农历
document.getElementById("clock").innerHTML=s;
//每隔500毫秒重新获取一下本机时间:
setTimeout("Draw()",500);
}
//开始显示:
Draw();