Realtime Click without using a form field
Posted: Fri Aug 09, 2002 3:35 pm
Hi, Hope this helps some poeple around here 
This script uses DOM so it only works with NS6+, IE5+, Mozilla 1.0.
Add the following code to the BODY tag.
And also where you want the clock to be...
That's it!!!!
This script uses DOM so it only works with NS6+, IE5+, Mozilla 1.0.
Code: Select all
function startTime(id)
{
var currentTime = new Date();
var hr = currentTime.getHours();
var mn = currentTime.getMinutes();
var sc = currentTime.getSeconds();
hr = eval(hr);
mn = eval(mn);
sc = eval(sc);
if(hr < 10)
{
hr = "0" + hr;
}
if(mn < 10)
{
mn = "0" + mn;
}
if(sc < 10)
{
sc = "0" + sc;
}
if(document.getElementById)
{
document.getElementById(id).childNodesї0].nodeValue = " - " + hr + ":" + mn + ":" + sc;
}
setTimeout("startTime('basicTime')",500);
}Code: Select all
onload="startTime('basicTime');"Code: Select all
<span id="basicTime"> </span>