Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clock since a determinate date!

Status
Not open for further replies.

kruxty

Programmer
Jul 17, 2001
197
PT
i don't know if this is the right forum, but if anyone can help me i'll be pleased.
i want to make a clock (months, days, hours, minutes, seconds) since a determinate date. e.g. (1 January 2003).
How can i do this?
 
Javascript Forum:

<script>

var startDate = new Date(&quot;1/1/2003&quot;)

function showTime(){
now = new Date();
milliSecs = now.getTime() - startDate.getTime()
//months is quirky - so I'll keep it simple
msSecs = 1000
msMins = msSecs * 60
msHours = msMins * 60
msDays = msHours * 24
days = Math.floor(milliSecs / msDays )
hours = Math.floor((milliSecs - (days * msDays)) / msHours)
minutes = Math.floor((milliSecs - (days * msDays) - (hours * msHours)) / msMins )
seconds = Math.floor((milliSecs - (days * msDays) - (hours * msHours) - (minutes * msMins)) / msSecs )

if (hours < 10){
hours = &quot;0&quot; + hours
}

if (minutes< 10){
minutes = &quot;0&quot; + minutes
}

if (seconds < 10){
seconds = &quot;0&quot; + seconds
}

document.myForm.timer.value = days + &quot;:&quot; + hours + &quot;:&quot; + minutes + &quot;:&quot; + seconds
timerID = setTimeout(&quot;showTime()&quot;,1000)
}
</script>

<body onLoad=&quot;showTime()&quot;>
<form name=&quot;myForm&quot;>
<input name=&quot;timer&quot;>
</form> Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Can i do this in a layer or any other thing invisible instead of the form?
 
You can do whatever you want with it. If you don't want it to display, you can make the <input type=hidden>. I'm not sure why you're doing it if not for display... Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
i wnat to show the numbers... not the form!
When i said invisble was the &quot;field&quot; where i put the counter... not the counter!
So... i think the example that you gave me don't work... :(
 
Just set the style the way you want it.....

<input name=&quot;timer&quot; style=&quot;border: 0px; font-family: arial&quot;>
Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top