Dynamic date and time with moment.js and setInterval

后端 未结 4 1541
忘了有多久
忘了有多久 2021-02-07 12:22

I\'m trying to find out how I can display dynamic date and time using moment.js.

Apparently I can\'t figure out to use setInterval properly.

If possible I\'d pre

4条回答
  •  無奈伤痛
    2021-02-07 12:34

    This is how it goes by me and its working u can check it here

    HTML
    

    < asp:Label ID="Label1" runat="server" Text='' >

    JavaScript
    < script language="javascript" type="text/javascript">
    function date_time() 
    {
    var dt = new Date();
    document.getElementById('<%=Label1.ClientID%>').innerHTML = dt;
    setTimeout(function () { date_time(); }, 1000);
    }
    date_time();
    < /script>
    

提交回复
热议问题