JS real-time display

    function show_cur_times () {
         // get the current date 
        var DATE_TIME = new new a Date ();
         // in 
        var year = date_time.getFullYear ();
         // Analyzing less than 10, fill front 0 
        IF (year <10 ) { 
            year = "0 "+ year; 
        } 
        // month 
        var month The date_time.getMonth = () +. 1 ;
         // Analyzing less than 10, fill front 0 
        IF (month The <10 ) { 
            month The =" 0 "+ month The; 
        } 
        // day 
        var day =date_time.getDate ();
         // Analyzing less than 10, fill front 0 
        IF (Day <10 ) { 
            Day = "0" + Day; 
        } 
        // when 
        var hours = date_time.getHours ();
         // Analyzing less than 10, the front complement 0 
        IF (hours <10 ) { 
            hours = "0" + hours; 
        } 
        // sub 
        var minutes = date_time.getMinutes ();
         // Analyzing less than 10, fill front 0 
        IF (minutes <10 ) { 
            minutes = "0 "+ minutes; 
        } 
        //Second 
        var seconds The = date_time.getSeconds ();
         // Analyzing less than 10, fill front 0 
        IF (seconds The <10 ) { 
            seconds The = "0" + seconds The; 
        } 
        // Minutes splicing date 
        var DATE_STR = + year "in "+ month +" month "+ day +" date "+ hours +": "+ minutes +": "+ seconds the;
         // display the id of showtimes containers 
        document.getElementById (" Times ") the innerHTML =. DATE_STR ; 
    } 
    // set one second function is called once show_cur_times 
    setInterval ( "show_cur_times ()", 100);

 

Guess you like

Origin www.cnblogs.com/mz0104/p/11089038.html