Topic: Need a dynamic Javascript clock that shows UTC time under any circumstances (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=29274" title="Pages that link to Topic: Need a dynamic Javascript clock that shows UTC time under any circumstances (Page 1 of 1)" rel="nofollow" >Topic: Need a dynamic Javascript clock that shows UTC time under any circumstances <span class="small">(Page 1 of 1)</span>\

 
paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

IP logged posted posted 06-10-2007 16:38 Edit Quote

Hi guys I need some help here.. I need a javascript clock component that displays the correct UTC time no matter what the time on the client machine is. Any ideas on this?

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 06-10-2007 18:47 Edit Quote

If by correct you mean correct within the margin of error of trip from the server to the client, then it's pretty easy to inject the UTC timestamp into the JS served to the client. Which script will use the UTC timestamp ( assuming the clock of the server is not completetly off either, but that's unlikely ) as the basis to instanciate a Date object. Voilà.

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 06-11-2007 09:33 Edit Quote

To reduce the error, you can create the SCRIPT tag with the injected UTC timestamp dynamically. Right before append'ing it, create a Date object, and calculate the difference at the end of the dynamic script ( the one with the injected UTC timestamp ).

HTH,



Post Reply
 
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
 
Your Text:
Loading...
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu