This topic contains 0 replies, has 1 voice, and was last updated by  Alex 6 months, 2 weeks ago.

  • Author
    Posts
  • #10345 Reply

    Alex
    <style style="text/css">
    .clock {
      font-size: 4em;
    }
    </style>
    <script>
    function clock() {// We create a new Date object and assign it to a variable called "time".
    var time = new Date(),
        
        // Access the "getHours" method on the Date object with the dot accessor.
        hours = time.getHours(),
        
        // Access the "getMinutes" method with the dot accessor.
        minutes = time.getMinutes(),
        
        
        seconds = time.getSeconds();
    
    document.querySelectorAll('.clock')[0].innerHTML = harold(hours) + ":" + harold(minutes) + ":" + harold(seconds);
      
      function harold(standIn) {
        if (standIn < 10) {
          standIn = '0' + standIn
        }
        return standIn;
      }
    }
    setInterval(clock, 1000);
    </script>
    <div class="clock"></div>
Reply To: Digital Clock using JavaScript in HTML Field
Your information:




+ 57 = 65