zoukankan      html  css  js  c++  java
  • js获取时间

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    
    <body>
    <div id="time"><span>当前时间:</span><div class="time" id="lclock"></div></div>
    </body>
    <script>
            function fortime() {
            var now=new Date();
            var year=now.getFullYear();
            var month=now.getMonth()+1;
            if(month<10){
                month='0'+month
            };
            var date=now.getDate();
            if(date<10){
                date='0'+date
            };
            var hour=now.getHours();
            if(hour<10){
                hour='0'+hour
            };
            var minute=now.getMinutes();
            if (minute<10){
                minute='0'+minute
            } ;
            var second=now.getSeconds();
            if(second<10){
                second='0'+second
            };
           
            myclock=year+"-"+month+"-"+date+"  "+hour+":"+minute+":"+second
            lclock.innerHTML=myclock; 
            setTimeout("fortime()",1000);
        }
           fortime();
    </script>
    </html>
  • 相关阅读:
    从小到大全排列
    众数-摩尔投票法
    链表复制
    2019.8.29刷题统计
    2019.8.28刷题统计
    2019.8.27刷题统计
    2019.8.26
    2019.8.25刷题统计
    2019.8.24
    2019.8.23刷题统计
  • 原文地址:https://www.cnblogs.com/shj-com/p/7240912.html
Copyright © 2011-2022 走看看