thanks.  That got me almost where I wanted to be.  this is what I used:

<cfoutput>
<script language="_javascript_1.2">
         <cf_nowdatetime>
         #nowmonthnbr#/#nowdaynbr#/#nowyearnbr#

         window.clientDate = new Date();
         window.serverDate = new Date("#jsStringFormat(dateFormat(now(),
'long') & '
         ' & timeFormat(now(), 'long'))#");

         if(navigator.appName == "Netscape") {
                 document.write('<layer id="clock"></layer><br>');
         }

         if (navigator.appVersion.indexOf("MSIE") != -1){
                 document.write('<span id="clock"></span><br>');
         }

         function updateClock() {
                 var curr = new Date(new Date().valueOf() -
window.clientDate.valueOf() + window.serverDate.valueOf());
                 var hrs = curr.getHours();
                 var min = curr.getMinutes();
                 var sec = curr.getSeconds();
                 var col = ":";
                 var sla = "/";
                 var spc = " ";
                 var apm;

                 if (12 < hrs) {
                         apm="PM";
                         hrs-=12;
                 } else {
                         apm="AM";
                 }

                 if (hrs == 0)
                         hrs=12;
                 if (min<=9)
                         min="0"+min;
                 if (sec<=9)
                         sec="0"+sec;

                 if(navigator.appName == "Netscape") {
                         document.clock.document.write(hrs+col+min+col+sec);
                         document.clock.document.close();
                 }

                 if (navigator.appVersion.indexOf("MSIE") != -1){
                         clock.innerHTML = hrs+col+min+col+sec;
                 }

         }

         setInterval("updateClock();", 1000);
</script>
</cfoutput>

At 12:25 PM 5/4/2004, you wrote:
>Here's a start.  It records a start time on the server and the client, and
>then uses a client-side delta to advance the server-side time for use in
>updating your display.  It will have an error equal to the time it takes
>from when the server-side date is written to the HTML buffer to when the
>client-side date is computed.  I have no idea of a way to get around that
>without an extra round trip with something like Rob's JS web services thing.
>
>
><cfoutput>
><script>
>window.clientDate = new Date();
>window.serverDate = new Date("#jsStringFormat(dateFormat(now(), 'long') & '
>' & timeFormat(now(), 'long'))#");
>
>
>function updateClock() {
>var curr = new Date(new Date().valueOf() - window.clientDate.valueOf() +
>window.serverDate.valueOf());
>// use the date to do whatever (probably write a div's content)
>alert(curr);
>}
>
>
>setInterval("updateClock();", 1000);
></script>
></cfoutput>
>
>Cheers,
>barneyb
>
>   _____
>
>From: kaigler [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, May 04, 2004 9:55 AM
>To: CF-Server
>Subject: I know this is not the right place for the code request but....
>
>I need some sort of _javascript_ clock that I can pass my server's time to and
>it can increment on the site.
>
>everything I see out there is using the users computer clock.
>
>ideas, site referrals?
>
>thanks,
>kaigler
>   _____
>
>----------
>[<http://www.houseoffusion.com/lists.cfm/link=t:10>Todays Threads]
>[<http://www.houseoffusion.com/lists.cfm/link=i:10:4892>This Message]
>[<http://www.houseoffusion.com/lists.cfm/link=s:10>Subscription]
>[<http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=6016.5469.10>Fast
>Unsubscribe] [<http://www.houseoffusion.com/signin/>User Settings]
>
>----------
><http://www.houseoffusion.com/banners/view.cfm?bannerid=38>
>[]
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to