js realizes dynamic display of time effect

  • 2021-07-26 06:32:10
  • OfStack

Without saying much, please look at the code:


<!DOCTYPE HTML> 
<html> 
<head> 
<meta charset="utf-8"> 
<title> Time display </title>  
</head> 
<body>
    <div id="d"></div> 
    <script type="text/javascript"> 
        var nowTime ;
        function play(){
        var time = new Date();
        nowTime = time.getFullYear()+" Year "+time.getMonth()+" Month "+time.getDate()+" Day "+time.getHours()+" Hour "+time.getMinutes()+" Points "+time.getSeconds()+" Seconds ";
        document.getElementById("d").innerHTML = nowTime;
        }
        setInterval(play,1000);
    </script>     
</body> 
</html>

Related articles: