title: Javascript digital timing in a form
body: <p>The script below displays a static date and Time.</p>
  
  <p><strong>How do I make the hours, minutes and seconds dynamic?</strong></p>
  
  <p>I want to show digital time changes (as on an electronic watch). </p>
  
  <p>I'm passing the variable in a form.</p>
  
  <pre><code>&lt;input id="date1" name="date1"&gt;
  
  &lt;script type="text/javascript"&gt;
  &lt;!--
  var currentTime = new Date()
  var month = currentTime.getMonth() + 1
  var day = currentTime.getDate()
  var year = currentTime.getFullYear()
  var hours = currentTime.getHours()
  var minutes = currentTime.getMinutes()
  var seconds = currentTime.getSeconds()
  
  document.write(month + "-" + day + "-" + year+ "-" + hours+ "-" + minutes+ "-" + seconds)
  
  document.getElementById('date1').value = (month + "-" + day + "-" + year+ "-" + hours+ "-" + minutes+ "-" + seconds);
  &lt;/script&gt;
  </code></pre>