+ 3
I want to link a program with the current date and time from the internet and not from the pc itself, how can i do that?
if x > real current date and time : do some thing
2 Respuestas
+ 2
Well for the computer date and time you would simply do this at the start of the program:
import datetime
As that will take the computers date and time.
I spoke to my coding friend about it and he uses this code and it works perfectly:
>>> from urllib.request import urlopen
>>> res = urlopen('ENTER THE WEBSITE YOU GET THE DATE AND TIME FROM')
>>> result = res.read().strip()
>>> result
b'2017-07-28 04:53:46'
>>> result_str = result.decode('utf-8')
>>> result_str
'2017-07-28 04:53:46'
Hope this helps :)
0
@Jacob Smith, thanks it works very well :)