HTML Display Current date

前端 未结 6 1391
日久生厌
日久生厌 2021-02-02 13:19

I am using website builder called \'clickfunnels\', and they don\'t support feature that would allow me to display current date. But, I can add custom html to it.

I was

6条回答
  •  青春惊慌失措
    2021-02-02 13:47

    var currentDate  = new Date(),
        currentDay   = currentDate.getDate() < 10 
                     ? '0' + currentDate.getDate() 
                     : currentDate.getDate(),
        currentMonth = currentDate.getMonth() < 9 
                     ? '0' + (currentDate.getMonth() + 1) 
                     : (currentDate.getMonth() + 1);
    
    document.getElementById("date").innerHTML = currentDay + '/' + currentMonth + '/' +  currentDate.getFullYear();
    

    You can read more about Date object

提交回复
热议问题