获取当前时间代码

 二维码 11
发表时间:2021-02-02 17:13作者:xjvae来源:xjvae网址:https://www.xjvae.cn

代码如下:

<html>

<center>

<head>

</head>

<body>

<div style="color:white;font-size:50px;background-color:white;width:320px;height:180px;left:-36px;text-align:center;line-height:180px;

background-image:url(http://*.jpg);

background-repeat:no-repeat;"

     <div class="container">

    <div><h1 id="t"></h1>

   </body>

    <script>

          function getTimes(){

               var date = new Date();

var hours = date.getHours();

var iMinute=date.getMinutes(); var iSecond=date.getSeconds();

               var hour=document.getElementById("vi-hour");

var minute=document.getElementById("vi-minute");

var second=document.getElementById("vi-second");

                hour.innerHTML = AddZero(hours);

minute.innerHTML = AddZero(iMinute);

second.innerHTML = AddZero(iSecond);

            }

           

            setInterval("getTimes()",1000);

           function AddZero(n){

         if(n<10){

      return "0"+n;

        }

       return ""+n;

           }

   </script><div class="widget_about"><ul class="countdown">

     <span id="vi-hour" class="hours">00</span>

     <class="Separator">:

     <span id="vi-minute" class="minutes">00</span>

     <class="Separator">:

      <span id="vi-second" class="seconds">00</span>

  </ul><section class="about"> </div>

    </ul></section>

  </div>

  </div>

</body>

</center>

</html>



调整图片位置:

标题栏高度:40,内容区上:-40,左:15px




图片预览:

当前时间.jpg