setTimeout Example
HTML
<div id="info"></div>
JavaScript
function printTheTime()
{
var time = new Date();
document.getElementById("info").innerHTML= time;
console.log (time);
// run it again:
setTimeout(printTheTime, 1000);
}
// run this in 500ms (1 second)
setTimeout(printTheTime, 1000);
// try using setInterval instead!