<psan id="showTime"></span>
<%Date date=new Date();%> //服务器时间
var time=parseInt('<%date.getTime()%>'); //得到服务器时间的毫秒数
var i=0;
function settime(){
var myyear,mymonth,myday,myhour,mymin,mysec,mytime;
if(i==0){
i=1;
}else{
time+=1000;
}
var mydate=new Date(time); //把毫秒数赋值进去
myyear=mydate.getFullYear();
mymonth=mydate.getMonth()+1;
myday=mydate.getDate();
myhour=mydate.getHours()<10?'0'+mydate.getHours():mydate.getHours();
mymin=mydate.getMinutes()<10?'0'+mydate.getMinutes():mydate.getMinutes();
mysec=mydate.getSeconds()<10?'0'+mydate.getSeconds():mydate.getSeconds();
mytime="现在是"+myyear+"年"+mymonth+“月”+myday+“日”+myhour+“:”+mymin+“:”+mysec;
document.getElementById("showTime").innerHTML=mytime;
setTimeout('settime()',1000);
}
settime();