参考参考
<script type="text/javascript">
var attime;
function check(a){ //小于10的分钟和秒前面加个0
if(a<10){
a = "0" + a;
}
return a;
}
function clock(){
var time=new Date();
attime=time.getHours() + ":" + time.getMinutes() + ":" + check(time.getSeconds());
document.getElementById("clock").value = attime;
}
setInterval(clock,1000);
</script>