首页 > 代码库 > js时钟

js时钟

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />    <title>shizhong</title>    <script language="javascript" >; function disptime() {          var time=new Date();  var hour=time.getHours();          var minute=time.getMinutes();          var second=time.getSeconds();           /*先来判断下 是上午还是下午*/           var am="AM";          if(hour>12){               hour=hour-12;               am="PM";                }           /*判断是不是要前置补零,一般情况下补零*/          if(minute<10)                minute="0"+minute;              if(second<10)            second="0"+second;           document.myform.myclock.value=hour+":"+minute+":"+second;           var Mytime=setTimeout("disptime()",1000); }  </script></head><body onload="disptime()">    <form name="myform">        <div align="15">            <input type="text" name="myclock" value="" size="15"></div>    </form></body></html>

 

js时钟