Skip to content

Instantly share code, notes, and snippets.

@HarryCoops
Last active August 29, 2015 14:25
Show Gist options
  • Save HarryCoops/fc3a6b9c1337a7eac7c5 to your computer and use it in GitHub Desktop.
Save HarryCoops/fc3a6b9c1337a7eac7c5 to your computer and use it in GitHub Desktop.
import time
import ntplib
def get_time():
'''Get atomic time from server and return it, along with the offset.'''
c = ntplib.NTPClient()
response = c.request('uk.pool.ntp.org', version=3)
return time.ctime(response.tx_time), response.offset
def main():
atom_time = get_time()
print('Atomic time:', atom_time[0])
print('Offset: ', atom_time[1])
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment