SO Answer / How to make Javascript time automatically update

See: http://stackoverflow.com/questions/10470825/how-to-make-javascript-time-automatically-update/10470995

by KooiInc MeHere

HTML

<div id="time_span"></div>

JavaScript

timer();

function timer(){
 var now = new Date,
     hours = now.getHours(),
     ampm  = hours<=11 ? ' AM' : ' PM'
     minutes = now.getMinutes(),
     seconds = now.getSeconds(),
     t_str = [hours-12,
              (minutes < 10 ? "0" + minutes : minutes),
              (seconds < 10 ? "0" + seconds : seconds)]
                 .join(':') + ampm;
 document.getElementById('time_span').innerHTML = t_str;
 setTimeout(timer,1000);
}