Monday 15 July 2019

How to get the Date and Time of Current Location in Python





I want to get the Date and Time of The Current Location. If somebody runs the code in a different country thought it will show the date and and time for them, and not for me. If you know any commands for this please put the down bellow. I prefer If I don't need a library so that people who get the code don't need to download the library.


Answer



I think you can not get the date or time of a location.



This code gets your device's date and time:




from datetime import datetime
now = datetime.now()

current_time = now.strftime("%H:%M:%S")
current_date = now.strftime("%D")

print("Current Time: ", current_time)
print("Current Date: ", current_date)


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...