/    Sign up×
Community /Pin to ProfileBookmark

javascript clock thats not for telling you the time

can some one please help me, i am useless at javascript and i would like to make a clock that keeps live time. My clock MUST tick by one second every 0.408333333333 seconds and has to be started on 00:00:00 then from when i start it tick one second ever 0.408333333333 is this posiable? can someone help?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FromU2MEJan 04.2006 — What do you have so far (code)?
Copy linkTweet thisAlerts:
@felgallJan 05.2006 — What is the significance of 0.40833333333?
Copy linkTweet thisAlerts:
@kinkJan 06.2006 — ive been waiting for a question like this...in order to satisfy your .408 requirment ive added a new input box and function i made this several months ago and update whenevr i see something like this heres the code i call it timekeeper one day it will have all possible manipulations of time

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Developer Studio">

<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">

<TITLE>Document Title</TITLE>

<style type="text/css">

body

{ background-color: 00000c;

color: 00aaaa;

font-size: 18;

font-weight: bold;

font-variant: small-caps;

}

input

{

background-color: 00000c;

color: 00aaaa;

font-size: 20;

font-weight: bold;

}

</style>

<script type="text/javascript">

function twxfunction()

{


var re = new Date();

setTimeout("twxfunction()",1000)

var hys = re.getHours();

var myn = re.getMinutes();

var sec = re.getSeconds();

if (sec < 10)(sec = "0" + sec);

if (myn < 10)(myn = "0" + myn);

if (hys < 10)(hys = "0" + hys);

var h = document.drw.da.value;


document.drw.da.value = hys + ":" + myn + ":" + sec ;




}

</script>

<script type="text/javascript">

function afunction()

{

var df = document.drw.dba.value;

var h = document.drw.da.value;

document.drw.dba.value = "" + h + "";

acfunction();

affunction()

document.getElementById("dcca").style.visibility="hidden";

}

</script>

<script type="text/javascript">

function acfunction()

{

var re = new Date();

setTimeout("acfunction()",1000)

var hys = re.getHours();

var myn = re.getMinutes();

var sec = re.getSeconds();

if (sec < 10)(sec = "0" + sec);

if (myn < 10)(myn = "0" + myn);

if (hys < 10)(hys = "0" + hys);



var rp = document.drw.dca.value;

var s = (sec * 0) + rp * 1 + 1;

document.drw.dca.value = s;

if(rp == 59)document.drw.dca.value = "0"



var p = document.drw.dcaz.value;

if(rp == 59)document.drw.dcaz.value = p * 1 + 1;

if(p == 59 && rp == 59)document.drw.dcaz.value = "0";

var q = document.drw.dcax.value;

if(p == 59 && rp == 59)document.drw.dcax.value = q * 1 + 1;

var bl = document.drw.dcas.value;

var bv = document.drw.dcaw.value;

document.drw.dcaw.value = (sec * 0) + bv * 1 + 1;

if(bv == 9)document.drw.dcaw.value = "0";

document.drw.dcas.value = (sec * 0) + bl * 1 + 1;

if(bl == 19)document.drw.dcas.value = "0";

var nh = document.drw.dvas.value;

document.drw.dvas.value = ("" + q + ":" + p + ":" + rp + "");


var np = document.dww.dwa.value;

var km = document.dww.dwaq.value;

document.dww.dwaq.value = np;

if(km > 0)document.dww.dwaq.value = km - 1;

if(km == "0")document.dww.dwaq.value = "0";

var bkm = document.dww.dwap.value;

if(km == "0")document.dww.dwap.value = "time expired";



}

</script>

<script type="text/javascript">

function affunction()

{

setTimeout("affunction()",408.333333333)

var wse = document.mfy.vf.value;

document.mfy.vf.value = wse *1 + 1;

}

</script>

</HEAD>

<BODY onload="twxfunction()" >






<table align="left"><tr><td>

<form name="drw">real time<br>

<br><input type="text" name="da" readonly="readonly"><br><br>

<br>start time<br>

<input type="text" name="dba" readonly="readonly"><br><br>


<br>elapsed time - seconds<br>

<input type="text" name="dca" readonly="readonly">

<br>minutes<br>

<input type="text" name="dcaz" readonly="readonly">

<br>hours<br>

<input type="text" name="dcax" readonly="readonly">

<br>interval(10 sec)<br>

<input type="text" name="dcaw" readonly="readonly">

<br>interval(20 sec)<br>

<input type="text" name="dcas" readonly="readonly">

<br>elapsed time interval<br>

<input type="text" name="dvas" readonly="readonly">

<br><br>

<input type="button" name="dcca" value="start clock" onclick="afunction()">

</form>

</td></tr></table>

<table align="right"><tr><td>

<form name="dww" align="right">enter countdown value<br>

<br><input type="text" name="dwa"><br>

<br>countdown<br><input type="text" name="dwaq" readonly="readonly"><br><input type="text" name="dwap" readonly="readonly"><br>

</form>

<br>

<form name="mfy">.408333333333 modified time<br>

<input type="text" name="vf"></form>

</td></tr></table>

<!-- Insert HTML here -->

</BODY>

</HTML>
Copy linkTweet thisAlerts:
@KorJan 06.2006 — anyway, nor even the internal clock of a computer is not as accurate. And even if it might be, the setTimeout() delay is not as accurate as you may think. It depends on the power/frequency of the processor, on the ussage of the CPU or memory... The error might rise upon 70-80 miliseconds/second
×

Success!

Help @discorev spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...