using time.gov to get the current time

Matt Nordhoff mnordhoff at mattnordhoff.com
Sat Dec 19 21:18:48 EST 2009


Matt Nordhoff wrote:
> Rick wrote:
>> Is there any way to get the current time from time.gov using urllib2 or something similar?
>>
>> Does anyone have any examples of doing this?
>>
>> Thanks!
>> Rick King
>> Southfield MI
> 
> Why isn't your local system's clock accurate enough?

Bah, I'm better at IRC than e-mail... Anyway:

The easiest way to get highly-accurate time is with an "apt-get install
ntp" (or your OS's equivalent), and that solves it for all of your
applications, not just this one.

The time synchronization solutions that exist today are the result of
decades of development by experts. If you try to write some solution
yourself, it will not be as accurate (though that's okay if it still
meets your accuracy requirements), and you're liable to make some
mistake* and wind up with a bunch of angry NTP server operators chasing
after you with torches and pitchforks.

* Such as making excessively-frequent requests, or making more frequent
requests if the server appears down, or ignoring NTP Kiss-o'-Death
packets. Do not do these things!
-- 
Matt Nordhoff



More information about the Python-list mailing list