Syncronizing A Web Page’s JavaScript Clock To Official Time Via AJAX / DOM
Recently asked on Yahoo! Answers:
Are there any JavaScripts to sync the date with time.gov?
I have the script to sync the date displayed with the visitor’s local computer.
Is there a way to “sync”, or display the date (i.e. march 8, 2007), on your web site automatically?
JavaScript clocks on Web pages are very popular; my quickie demo site uses one. And as I’ve discussed in previous entries, the problem — as this questioner notes — is that you never know what time a user’s computer may be showing, and it’s whatever time that user’s computer believes it to be that JavaScript will display on a Web page.
What we need is a reliable source of time from some knowledgeable arbiter — and some method of getting that information on a Web page, that can be updated every second. Thanks to AJAX, PHP and the US Naval Observatory’s Time Department, we have all those ingredients.
Continue reading ‘Syncronizing A Web Page’s JavaScript Clock To Official Time Via AJAX / DOM’ »