日期:2014-05-19 浏览次数:20866 次
<script type="text/javascript">
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning){
clearTimeout(timerID);
timerRunning = false;
}
}
function startclock(){
stopclock();
showtime();
}
function showtime(){
var now= new Date();
var year=now.getYear();
var month=now.getMonth()+1;
var day=now.getDate();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
var timeValue =year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
document.getElementsByName("XXX")[0].value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
</script>
<body onload="startclock()">