Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div id="id_of_element_you_want_to_contain_time">--:--:--</div>
  <script>
    (function() {
      var elm = document.getElementById("id_of_element_you_want_to_contain_time");
      
      setInterval(updateTime, 1000);
      
      function updateTime() {
        var now = new Date(),
            hours = zeropad(now.getHours(), 2),
            minutes = zeropad(now.getMinutes(), 2),
            seconds = zeropad(now.getSeconds(), 2);
        
        elm.innerHTML = hours + ":" + minutes + ":" + seconds;
      }
      
      function zeropad(str, width) {
        str = String(str);
        while (str.length < width) {
          str = "0" + str;
        }
        return str;
      }
    })();
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers