Start Timer in javascript For Beginners

Sabarimahesh
Posted by Sabarimahesh under JavaScript category on | Points: 40 | Views : 1700
<html>
<head>
<script type="text/javascript">


function ST_Time()
{
var Tdy=new Date();
var h=Tdy.getHours();
var m=Tdy.getMinutes();
var s=Tdy.getSeconds();
m=chk_time(m);
s=chk_time(s);12:54:21
document.getElementById('txt_sdf').innerHTML=h+":"+m+":"+s;
t=setTimeout('ST_Time()',500);
}

function chk_time(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>

<body onload="ST_Time()">
<div id="txt_sdf"></div>
</body>
</html>

Comments or Responses

Login to post response