Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1479 How can I have a clock on a webpage that syncs with the Atomic clock?

You are here: irt.org | FAQ | JavaScript | Date | Q1479 [ previous next ]

Have an image and change the source:

<script language="JavaScript"><!--
function showTime() {
   if (!document.images) return;
   now = new Date();
   document.images["theTime"].src = 'http://tycho.usno.navy.mil/cgi-bin/xbmclock.xbm?zone=GMT&'+ now.getTime();
   setTimeout('showTime()',60000); // update once a minute or they will be cross...
}
//--></script>

<img name="theTime" src="http://tycho.usno.navy.mil/cgi-bin/xbmclock.xbm?zone=GMT" width=192 height=28>

More info (timezone and such) at http://tycho.usno.navy.mil/howclock.html

©2018 Martin Webb