How can i get my local time with python?

datetime

#1

datetime gives new york time. How can i get my local time with python?


What does importing a library do?
#2

If you are running this code online then the program will return time of server where the code is originally executing (if Codecademy, then maybe their NY server).

Try running this on your own machine. Works fine for me.

>>> from datetime import datetime
>>> print datetime.now()
2018-09-27 10:27:29.733000

#3

That puts you z = +6 by my reckoning. We’re on opposite sides of the globe. Your English is good enough I’m gonna place you in India, somewhere.


#4

That was a great deduction :smiley:


#5

I confess upon reading “Glimpses of World History” and tried to imagine being a 13 year-old reading it in letter form… In English. So I guess that would explain my strange reasoning. Not to mention the added bias I got from “A Passage to India”. I know the language of the majority is not English, but in that region of the world, the best English speakers are on the sub-continent.