Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find offset between system-time and Internet time using Python

How would you find the time offset between the local OS system-time and Internet time from various Internet time sources using Python?

like image 367
Jonathan Livni Avatar asked Aug 01 '26 01:08

Jonathan Livni


1 Answers

Use ntplib. Right from the manual:

>>> import ntplib
>>> c = ntplib.NTPClient()
>>> response = c.request('europe.pool.ntp.org', version=3)
>>> response.offset
-0.143156766891
like image 55
phihag Avatar answered Aug 02 '26 14:08

phihag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!