首页 > 解决方案 > How to fetch date and time from internet

问题描述

My problem is that, I want to fetch correct date and time, but if we change time in our local system/PC our datetime module will not fetch the correct date, it'll just fetch what time/date our machine have.

Code I tried:

from datetime import datetime

dt = datetime.now().strftime("%H:%M:%S-:-%d:%m:%Y")
print(dt)

Now this code will only print the time which I set on this machine, but I don't know how to fetch date and time from web, like fetch it from any website or something, pls tell me the correct way to fetch correct date and time!

Every answer will be appreciated

THANKS

PS: SORRY FOR BAD ENGLISH

标签: pythondatedatetimetime

解决方案


推荐阅读