获取系统时间

来源:互联网 发布:怎么修改淘宝评价手机 编辑:程序博客网 时间:2024/05/29 16:03

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>显示系统时间</title>
<script>
    varsecond;    //全局变量秒
    functionGetSeconds()   //秒的增加
    
    second++;  
    GetTime();
 }
    functionGetTime()   //循环获取系统时间
 {
  var time = new Date();
  var hour =time.getHours();    //获得当前的小时
  var minute =time.getMinutes();  //获得当前的分钟数
  second =time.getSeconds();   //获得当前的秒数
  
  //判断小于10的时候十位补0
  if(minute<10)
    minute = "0"+minute;
  if(second<10)
    second = "0"+second;
    
    //判断小时
  document.form1.txtTime.value ="现在时间是:"+hour+":"+minute+":"+second;
 }
</script>
</head>

<bodyonload="GetTime();setInterval('GetSeconds()',1000)">
<form id="form1" name="form1" method="post"action="">
  <label>
  <input type="text" name="txtTime"/>
  </label>
</form>

</body>
</html>

0 0
原创粉丝点击