js获取当前时间显示

    xiaoxiao2021-03-25  76

    <script type="text/javascript"> window.onload = function() { var showDay = document.getElementById("showDay"); var showTime = document.getElementById("showTime"); setInterval(function() { var time = new Date(); // 程序计时的月从0开始取值后+1 var m = time.getMonth() + 1; var day = time.getFullYear() + "年" + m + "月"+ time.getDate() + "日 "; var t = time.getHours() + ":"+ time.getMinutes() + ":" + time.getSeconds(); showDay.innerHTML = day; showTime.innerHTML=t; }, 1000); }; </script> <html> <body> <h2 style="display:inline-block">此刻  </h2><h5 style="display:inline-block;color:gray" id="showTime"></h5> <h2 style="display:inline-block">今日  </h2><h5 style="display:inline-block;color:gray" id="showDay"></h5> </body></html>
    转载请注明原文地址: https://ju.6miu.com/read-22628.html

    最新回复(0)