JS realizes dynamic display time (the easiest way)

Use JS to realize dynamic display time

The easiest way to achieve

Insert the following js code directly into the appropriate position of the webpage, (id="datetime") cannot be omitted.

<div id="datetime">
 <script>
      setInterval("document.getElementById('datetime').innerHTML=new Date().toLocaleString();", 1000);
 </script>
</div>

The effect is as follows:

2020/9/30 2:24:13 PM


Guess you like

Origin blog.csdn.net/ITMuscle/article/details/109173339