title: How to make Javascript time automatically update
body: <p>I am using the following Javascript code to display the time on my website. How can I make this update automatically.</p>
  
  <p>Thanks</p>
  
  <pre><code>&lt;section class="portlet grid_6 leading"&gt; 
  &lt;header&gt;
  &lt;h2&gt;Time&lt;span id="time_span"&gt;&lt;/span&gt;&lt;/h2&gt;
  &lt;/header&gt;
  &lt;script type="text/javascript"&gt;
  var currentTime = new Date()
  var hours = currentTime.getHours()
  var minutes = currentTime.getMinutes()
  if (minutes &lt; 10){
      minutes = "0" + minutes
  }
  var t_str = hours + ":" + minutes + " ";
  if(hours &gt; 11){
      t_str += "PM";
  } else {
     t_str += "AM";
  }
  document.getElementById('time_span').innerHTML = t_str;
  &lt;/script&gt;
  &lt;/section&gt;
  </code></pre>