import ntplib
from time import ctime
import datetime

us_server = '1.us.pool.ntp.org'
thailand_server = '1.th.pool.ntp.org'
austria_server = '0.at.pool.ntp.org'

print("Accessing the US '{}'\n".format(us_server))

c = ntplib.NTPClient()
response = c.request(us_server, version=4)
    
print("\tDetails for '{}' at IP: {}".format(us_server, ntplib.ref_id_to_text(response.ref_id)))
print("\tOffset: {:6.4f} millsecs\t".format(response.offset))

print("\tThe server says the current time is: {}".format(ctime(response.tx_time)))

print("*" * 60)

print("Accessing the Thailand '{}'\n".format(thailand_server))

c = ntplib.NTPClient()

response = c.request(thailand_server, version=4)

print("\tDetails for '{}' at IP: {}".format(thailand_server, ntplib.ref_id_to_text(response.ref_id)))
print("\tOffset: {:6.4f} millsecs\t".format(response.offset))

print("\tThe server says the current time is: {}".format(ctime(response.tx_time)))

print("*" * 60)

print("Now we will ask the Austrian '{}' for the UTC time".format(austria_server))
x = ntplib.NTPClient()
print(datetime.datetime.utcfromtimestamp(x.request('europe.pool.ntp.org').tx_time))

