Can i ask what the function of setTimeOut method in javascript?As below:
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.get
setTimeOut sets a timer and executes the given code after that timer timed out. So using your code, if startTime is called once, it is repeated every half second.
Btw. I assume the delay of 500 ms is used te work around small deviations in the clock. You will want to update the value of the element every whole second. To do that, it is better to calculate the time until the next whole second and set that as a delay. This will give you a more accurate clock.