HTML how do I insert dynamic date in webpage

前端 未结 8 2057
暖寄归人
暖寄归人 2021-01-05 14:40

I have a static webpage, nothing changes dynamically. However the client wants a date insert into text within the page. The date will always be the current daet plus one day

8条回答
  •  抹茶落季
    2021-01-05 15:25

    window.onload = initDate;
    function initDate() {
         var dayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday","Saturday");
         var monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
         var now = new Date();
         var dtString = dayName[now.getDay()] + ", " + monName[now.getMonth()] + " " + now.getDate();
         document.getElementById("dtField"). innerHTML = dtString;
    }
    

    Source

提交回复
热议问题