Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ntplib
- from datetime import datetime, timezone
- c = ntplib.NTPClient()
- # Provide the respective ntp server ip in below function
- response = c.request('uk.pool.ntp.org', version=3)
- response.offset
- # UTC timezone used here, for working with different timezones you can use [pytz library][1]
- currenttime =datetime.fromtimestamp(response.tx_time, timezone.utc)
- print (currenttime)
- d = map(int, str(currenttime))
- print (list(d))
- 2019-07-15 20:56:19.952231+00:00
- ValueError: invalid literal for int() with base 10: '-'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement