获取系统当前时间啊 一个js搞定 <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("time")[0].value = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } //--> </script> <body onload="startclock ()"> <input type="text" name="time"/> </body>
一个js搞定
<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("time")[0].value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
//-->
</script>
<body onload="startclock ()">
<input type="text" name="time"/>
</body>