a guest Jul 15th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import ntplib
  2. from datetime import datetime, timezone
  3. c = ntplib.NTPClient()
  4.         # Provide the respective ntp server ip in below function
  5. response = c.request('', version=3)
  6. response.offset
  7.         # UTC timezone used here, for working with different timezones you can use [pytz library][1]
  8. currenttime =datetime.fromtimestamp(response.tx_time, timezone.utc)
  9. print (currenttime)
  10. d = map(int, str(currenttime))
  11. print (list(d))
  13. 2019-07-15 20:56:19.952231+00:00
  15. ValueError: invalid literal for int() with base 10: '-'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand