+ 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

2nd Nov 2017, 10:43 AM
Ahmed Kamal
Ahmed Kamal - avatar
2 Respostas
+ 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 :)
2nd Nov 2017, 12:16 PM
Jacob Smith
Jacob Smith - avatar
0
@Jacob Smith, thanks it works very well :)
3rd Nov 2017, 6:52 AM
Ahmed Kamal
Ahmed Kamal - avatar