Dispaly clock using javascript?

aswinialuri-19361
Posted by aswinialuri-19361 under ASP.NET category on | Points: 40 | Views : 844
code in .aspx page
<script type="text/javascript">
function startTime()

{

var today=new Date();

var h=today.getHours();

var m=today.getMinutes();

var s=today.getSeconds();

// add a zero in front of numbers<10

m=checkTime(m);

s=checkTime(s);

document.getElementById('txt').innerHTML=h+":"+m+":"+s;

t=setTimeout(function(){startTime()},500);

}



function checkTime(i)

{

if (i<10)

{

i="0" + i;

}

return i;

}

</script>

</head>



<body onload="startTime()">

<div id="txt"></div>

</body>

Comments or Responses

Posted by: Rimi1289 on: 7/29/2013 Level:Starter | Status: [Member] | Points: 10
Really nice. Also you can create an animated digital clock using JavaScript and HTML. No images.
http://www.encodedna.com/2012/11/javascript-digital-clock.htm

Login to post response