获取当前时间的代码

如标题:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> Test  Date Now </title>
  <script type="text/javascript">
        window.onload = function() { 
            var show = document.getElementById("show"); 
            setInterval(function() {  
                var time = new Date();   // 程序计时的月从0开始取值后+1  
                var m = time.getMonth() + 1;  
                var t = time.getFullYear() + "-" + m + "-"    
                    + time.getDate() + " " + time.getHours() + ":"    
                    + time.getMinutes() + ":" + time.getSeconds();  
                    show.innerHTML = t; 
                     
                    //console.info(t);
            }, 1000);
 
        };
</script>
 
 </head>
 
 <body>
  <div id="show"></div>
 </body>
</html>

  

 

posted @   xh_Blog  阅读(1196)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示