动态时钟

<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>动态时钟</title>
 <script type="text/javascript">
 function time(){
  var currentDate=new Date();
  var year=currentDate.getFullYear();
  var month=currentDate.getMonth()+1;
  var day=currentDate.getDate();
  var h=currentDate.getHours()
  var m=currentDate.getMinutes()
  var s=currentDate.getSeconds()
  m=checkTime(m)
  s=checkTime(s)
  document.getElementById('txt').innerHTML=year+"-"+month+"-"+day+" "+h+":"+m+":"+s
  t=setTimeout('time()',1000);
 }
 function checkTime(i){
  if(i<10){
   i="0"+i
  }
  return i
 }
 </script>
</head>
<body onload="time();">
 <div id="txt"></div>
</body>
</html>
阅读更多
换一批

没有更多推荐了,返回首页