페이지 실시 간 업데이트 시간의 JS 인 스 턴 스 코드

2101 단어
 
  
function startTime() {
                     var today = new Date(); //   
                     var yyyy = today.getFullYear(); // getFullYear()    
                     var MM = today.getMonth() + 1; // getMonth()    
                     var dd = today.getDate(); // getDate()     
                     var hh = today.getHours(); // getHours   
                     var mm = today.getMinutes(); // getMinutes   
                     var ss = today.getSeconds(); // getSeconds   
                     // 10, 0, 3 20 9 , 15:20:09  
                     MM = checkTime(MM);
                     dd = checkTime(dd);
                     mm = checkTime(mm);
                     ss = checkTime(ss);
                     var day; // (getDay() )
                     if (today.getDay() == 0) day = " "
                     if (today.getDay() == 1) day = " "
                     if (today.getDay() == 2) day = " "
                     if (today.getDay() == 3) day = " "
                     if (today.getDay() == 4) day = " "
                     if (today.getDay() == 5) day = " "
                     if (today.getDay() == 6) day = " "
                     document.getElementById('nowDateTimeSpan').innerHTML = yyyy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss + "   " + day;
                     setTimeout('startTime()', 1000); // startTime()
                 }

                 function checkTime(i) {
                     if (i < 10) {
                         i = "0" + i;
                     }
                     return i;
                 }


호출: 현재 시간:

좋은 웹페이지 즐겨찾기