Saturday, 1 October 2011

How to update current time using javascript


<html>
<head>
<title>(Type a title for your page here)</title>
<script type="text/javascript">
function display_c(){
var refresh=1000; // Refresh rate in milli seconds
mytime=setTimeout('display_ct()',refresh)
}

function display_ct() {
var strcount
var x = new Date()
document.getElementById('ct').innerHTML = x.getHours() +" : " +x.getMinutes() +" : "+ x.getSeconds();
tt=display_c();
}
</script>
</head>

<body onload=display_ct();>
<span id='ct' ></span>

</body>

</html>

1 comments:

Wow, This works awesome.
I was looking for this kind of JavaScript from a long time. This shows seconds perfectly and also this keep updating the seconds part of the time.

Thanks a lot... keep posting such useful and wonderful tricky stuffs...!!

Post a Comment