<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>動态時間</title>
<?php date_default_timezone_set("Asia/Shanghai");//地區?>
<script type="text/javascript" language="javascript">
window.οnlοad=function (){
stime();
}
var c=0;
var Y=<?php echo date('Y')?>,M=<?php echo date('n')?>,D=<?php echo date('j')?>;
function stime() {
c++
sec=<?php echo time()-strtotime(date("Y-m-d"))?>+c;
H=Math.floor(sec/3600)%24
I=Math.floor(sec/60)%60
S=sec%60
if(S<10) S='0'+S;
if(I<10) I='0'+I;
if(H<10) H='0'+H;
if (H=='00' & I=='00' & S=='00') D=D+1; //日進位
if (M==2) { //判斷是否為二月份******
if (Y%4==0 && !Y%100==0 || Y%400==0) { //是閏年(二月有28天)
if (D==30){M+=1;D=1;} //月份進位
}
else { //非閏年(二月有29天)
if (D==29){M+=1;D=1;} //月份進位
}
}
else { //不是二月份的月份******
if (M==4 || M==6 || M==9 || M==11) { //小月(30天)
if (D==31) {M+=1;D=1;} //月份進位
}
else { //大月(31天)
if (D==32){M+=1;D=1;} //月份進位
}
}
if (M==13) {Y+=1;M=1;} //年份進位
setTimeout("stime()", 1000);
document.getElementById("servertime").innerHTML = Y+'-'+M+'-'+D+' '+H+':'+I+':'+S
}
</script>
</head>
<body>
<span id="servertime"></span>
<!--動态擷取伺服器時間 -->
</body>
</html>