Pure JS implementation dynamic time display code

  • 2020-03-30 01:38:14
  • OfStack

<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Headless document </title>
 <script language="javascript">
     var t = null;
    t = setTimeout(time,1000);//Start to perform
    function time()
       clearTimeout(t);//Clear timer
       dt = new Date();
       var h=dt.getHours();
       var m=dt.getMinutes();
       var s=dt.getSeconds();
       document.getElementById("timeShow").innerHTML =  " The current time is: "+h+" when "+m+" points "+s+" seconds ";
       t = setTimeout(time,1000); //Set timer, loop execution & NBSP;                      
<label id="timeShow"></lable>

Related articles: