デジタル時計

デジタルらしく”0″ を付けました。

window.onload = function() {
  function time() {
    var now = new Date();
    var nowHours = now.getHours();
    var nowMinutes = now.getMinutes();
    var nowSeconds = now.getSeconds();
    if (nowMinutes < 10) nowMinutes = "0" + now.getMinutes();
    if (nowSeconds < 10) nowSeconds = "0" + now.getSeconds();
    strTime = nowHours + ':' + nowMinutes + ':' + nowSeconds;
    document.getElementById('clock').innerHTML = strTime;
  }
  setInterval(time, 1000);
}