Search code examples
pythonsystemtime

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?


Solution

  • Use ntplib. Right from the manual:

    >>> import ntplib
    >>> c = ntplib.NTPClient()
    >>> response = c.request('europe.pool.ntp.org', version=3)
    >>> response.offset
    -0.143156766891