JSFiddle - React, Tailwind, and code Playground

HTML

<div id="txt"></div>

<script type="text/javascript">
    //透過 document 物件與 id 取得網頁元素
    window.setInterval(function(){ 
    var currentTime = new Date();// 取得現在時間
       document.getElementById("txt").innerHTML = currentTime.toString();
    
    },1000);//1000 毫秒,意謂著一秒更新一次

</script>