Friday, August 10, 2007

JavaScript Program To Display Date and Current Time

<html>
<head>
<script type="text/javascript">
function TickTick()
{
var today=new Date()
var dd = today.getDate();
var mm = today.getMonth();
var yy = today.getFullYear();
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
m=secTicker(m)
s=secTicker(s)

document.getElementById('Clock').innerHTML="<strong>"+dd+"-"+mm+"-"+yy+" (dd/mm/yyyy)<br/>"+h+":"+m+":"+s+"</strong>";
t=setTimeout('TickTick()',1000)


}

function secTicker(i)// This Function is to add zero before minutes and second value which is less than 10
{
if (i < 10){i = "0" + i}return i; }
</script>
</head>

<body onload="TickTick()">
<div id="Clock"></div>

</body>
</html>

OutPut



No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.