Javascript与服务器同步时间
注意:这段要在保存成 asp 才可使用
<span id="dtxx">0</span>
<script language=javascript>
//与服务器时间同步
function time(dtxx){
var s='';
var d=dtxx!=null?new Date(dtxx):new Date();
with(d){
s=fixNum(getHours())+':'+fixNum(getMinutes())+':'+fixNum(getSeconds())
}
return(s);
}
function fixNum(num){
return num<10?'0'+num:num;
}
<%nowdate = year(now())&"/"&month(now())&"/"&day(now())&" "&hour(now())&":"&minute(now())&":"&second(now())%>
var dd=new Date("<%=nowdate%>");
parent.dtxx.innerHTML="";
setInterval("dd.setSeconds(dd.getSeconds()+1);parent.dtxx.innerHTML='<strong>'+time(dd)+'</strong> '",1000)
</script>