But I want to remove the date, to show only time and make it stand alone, not in an input filed.
Here is the code I have: <!-- Clock in Java Script .. Cameron Gregory http://www.bloke.com/ // http://www.bloke.com/javascript/Clock/ speed=1000; //len=28; len=25; tid = 0; num=0; clockA = new Array(); offsetA = new Array(); dd = new Date();
function doDate(x) { for (i=0;i<num;i++) { dt = new Date();
function start() { clockA[num] = document.forms["form"+num]; //offsetA[num] = 0; //window.alert( (new Date()).getTimezoneOffset()); d = new Date(); if (navigator.appVersion.substring(0,3) == "2.0") offsetA[num] = (d.getTimezoneOffset()*60*1000); else offsetA[num] = -(d.getTimezoneOffset()*60*1000); if (num == 0) tid=window.setTimeout("doDate()",speed); num++; }
function startLong(diff) { //window.alert("hay" + (new Date()).toGMTString()); clockA[num] = document.forms["form"+num]; //offsetA[num] = (diff - dd.getTimezoneOffset())*60*1000; offsetA[num] = (diff)*60*1000; //offsetA[num] = (-diff)* 60*1000; if (num == 0) tid=window.setTimeout("doDate()",speed); num++; }
function cleartid() { window.clearTimeout(tid); }
// for some reason on some pages this crashes netscape function Clock() { document.write('<FORM name=form'+num+'><input name=date size=') document.write(len) document.write(' value="Clock: Requires Javascript"></FORM>') start(); }
// for some reason on some pages this crashes netscape function ServerClock(diff) { document.write('<FORM name=form'+num+'><input name=date size=') // we chop the end, because it would be the wrong timezone document.write(25); //document.write(19) document.write(' value="Clock: Javascript"></FORM>') startLong(diff); } // end-->
I would be grateful if someone here could give me some tips on how to achieve this.
The clock originally shows up with a date and time in a form input field, like on this website (code source): http://www.bloke.com/javascript/Clock/server.html
But I want to remove the date, to show only time and make it stand alone, not in an input filed.
Here is the code I have:
<!-- Clock in Java Script .. Cameron Gregory http://www.bloke.com/
// http://www.bloke.com/javascript/Clock/
speed=1000;
//len=28;
len=25;
tid = 0;
num=0;
clockA = new Array();
offsetA = new Array();
dd = new Date();
function doDate(x)
{
for (i=0;i<num;i++) {
dt = new Date();
if (offsetA[i] != 0) {
gt = dt.getTime();
gt = gt + offsetA[i];
dt.setTime(gt);
}
clockA[i].date.value = dt.toGMTString();
}
tid=window.setTimeout("doDate()",speed);
}
function start() {
clockA[num] = document.forms["form"+num];
//offsetA[num] = 0;
//window.alert( (new Date()).getTimezoneOffset());
d = new Date();
if (navigator.appVersion.substring(0,3) == "2.0")
offsetA[num] = (d.getTimezoneOffset()*60*1000);
else
offsetA[num] = -(d.getTimezoneOffset()*60*1000);
if (num == 0)
tid=window.setTimeout("doDate()",speed);
num++;
}
function startLong(diff) {
//window.alert("hay" + (new Date()).toGMTString());
clockA[num] = document.forms["form"+num];
//offsetA[num] = (diff - dd.getTimezoneOffset())*60*1000;
offsetA[num] = (diff)*60*1000;
//offsetA[num] = (-diff)* 60*1000;
if (num == 0)
tid=window.setTimeout("doDate()",speed);
num++;
}
function cleartid() {
window.clearTimeout(tid);
}
// for some reason on some pages this crashes netscape
function Clock()
{
document.write('<FORM name=form'+num+'><input name=date size=')
document.write(len)
document.write(' value="Clock: Requires Javascript"></FORM>')
start();
}
// for some reason on some pages this crashes netscape
function ServerClock(diff)
{
document.write('<FORM name=form'+num+'><input name=date size=')
// we chop the end, because it would be the wrong timezone
document.write(25);
//document.write(19)
document.write(' value="Clock: Javascript"></FORM>')
startLong(diff);
}
// end-->