Re: hwg-techniques-digest V1 #1162
by David Sampson <david_sampson(at)eed.state.ak.us>
|
Date: |
Mon, 16 Apr 2001 15:59:51 -0800 |
To: |
hwg-techniques(at)mail.hwg.org, hwg-techniques-digest(at)mail.hwg.org |
In-Reply-To: |
|
|
todo: View
Thread,
Original
|
|
At 09:55 AM 4/12/01 -0600, hwg-techniques-digest wrote:
>I have a javascript running on our homepage which counts down days from a
>set date. My problem is that the number of days turns over at 12 noon
>instead of 12 midnight.
Anita:
Here's a script I lifted off the site that was tracking Mir's reentry. I'm
using it on my page to countdown to my 50th birthday. It counts down based
upon Grenwitch mean time so you'll have to figure how many hours to add
(heading west) or subtract (heading east) for your time zone.
Add this to the <Head> of your page and set accordingly (just place your
"blastoff time/date in the var eventdate= line:
<SCRIPT><!--
var eventdate = new Date("October 04, 2001 03:15:00 GMT");
function toSt(n)
{s=""
if(n<10) s+="0"
return s+n.toString();
}
function countdown()
{
d=new Date();
count=Math.floor((eventdate.getTime()-d.getTime())/1000);
if(count<=0) { return;}
var sec=toSt(count%60);
count=Math.floor(count/60);
var min=toSt(count%60);
count=Math.floor(count/60);
var hrs=toSt(count%24);
count=Math.floor(count/24);
var days=count;
document.write("<font size=3 face='Times New Roman,Georgia,Times'>"+days
+ " Days " + hrs + " Hours " + min + " Minutes");
}
// -->
</SCRIPT>
Then, add this to the appropriate place in the body of your page:
<center>
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td bgcolor="#b2b2b2"><font face="Times New Roman,Georgia,Times"
size="3"><b>Approximate Time Until David Turns 50</b></font></td>
</tr>
/table>
<script><!--
countdown()
// -->
</script>
</center>
You can wiggle the variables to include seconds if you want (I don't use
this function on my page though)
HTH
David
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA