Server time ticking clock v2.0 | JavaScriptSource

Server time ticking clock v2.0

Tom Leung Aug 26, 2004

"This script allows you not only to display a ticking clock in a web page, you can also set the initial time by perl script, php etc, so that server time can be shown to client.

Bugs fixed:

  1. Replaced setTimeout with setInterval. The setTimeout loop in v1.0 had in place will cause recursion to eat memory.
  2. I optimized the second++ logic that ripples through the minutes and hours.
  3. I combined the logic on seconds, minutes, hours for making 2 digits into a function call.
  4. i made the seconds,minutes,hours vars global so they can easily work with the setInterval
  5. Greatly reduced the delay between client time and server time due to the complex loop in v1.0 (Special thanks to js-x.com)

This script allows you not only to display a ticking clock in a web page, you can also set the initial time by perl script, php etc, so that server time can be shown to client.

Furthermore, if the server time is synchronized with NTP servers, the time shown in the web page will be absolutely precise."

Leave a Response

(0 comments)