Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  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('uk.pool.ntp.org', 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))
  12.  
  13. 2019-07-15 20:56:19.952231+00:00
  14.  
  15. ValueError: invalid literal for int() with base 10: '-'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement