如何通过 php 从服务器获取第一次?
我已经测试了这段代码,但它不起作用。它得到了时间,但它没有计数?有什么问题?
<script type="text/javascript">
function GetClock(){
d = new Date(<?php echo date("y, n, j, G, i, s");?>);
nhour = d.getHours();
nmin = d.getMinutes();
nsec = d.getSeconds();
if(nhour == 0) {
ap = " AM";nhour = 12;
} else if(nhour <= 11) {
ap = " AM";
} else if(nhour == 12) {
ap = " PM";
} else if(nhour >= 13) {
ap = " PM";nhour -= 12;
}
if(nmin <= 9) {
nmin = "0" +nmin;
} if(nsec <= 9) {
nsec = "0" +nsec;
}
document.getElementById('clockbox').innerHTML=""+nhour+":"+nmin+":"+nsec+ap+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;
</script>