Before we begin this javascript codes is program to get the current Time on your Computer but not the place or country you are in....
<html>
<head><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<10m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)//you can change the name of your function to any name you desired but remember to declare it first in the s=checkTime(s) and m=checkTime(m)
{if (i<10)
{
i="0" + i;
}
return i;
}
</script></head>
<body onload="startTime()"><div id="txt"></div>
</body>
</html>
Remember you will insert the blue javascript codes in the head section of your HTML codes..
<html>
<head><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<10m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)//you can change the name of your function to any name you desired but remember to declare it first in the s=checkTime(s) and m=checkTime(m)
{if (i<10)
{
i="0" + i;
}
return i;
}
</script></head>
<body onload="startTime()"><div id="txt"></div>
</body>
</html>
Remember you will insert the blue javascript codes in the head section of your HTML codes..
No comments:
Post a Comment