如何制作实时时钟 Yii2

How to make live clock Yii2

我想问如何在Yii2中制作活钟
我已经用谷歌搜索了,但没找到。 有它的小部件吗?抱歉,我是 Yii2 的初学者 谢谢

<script>
    var nameOfDay = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    var nameOfMonth = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'Desember');
    var data = new Date();
    function clock()
    {

    var hou = data.getHours();
    var min = data.getMinutes();
    var sec = data.getSeconds();
    if(hou<10){ hou= "0"+hou;}
    if(min<10){ min= "0"+min;}
    if(sec<10){ sec= "0"+sec;}

    document.getElementById('clock').innerHTML = hou+":"+min+":"+sec;
        data.setTime(data.getTime()+1000)
        setTimeout("clock();",1000);

    document.getElementById('date').innerHTML = nameOfDay[data.getDay()] + ", " + nameOfMonth[data.getMonth()] + " " + data.getDate() + ", " + data.getFullYear();
    }

    </script>
    <body onload="clock()">
    <h2>Current Server Time:</h2>
    <h1><div id="clock"></div></h1>
    <h3><div id="date"></h3>