Datetime--time zone?


#1

from datetime import datetime
now = datetime.now()
print ‘%02d:%02d:%04d’ % (now.hour, now.minute, now.second)

This gives me a time of 19:55:0040 or 7:55:0040 when it is actually 3:00 PM, 15:00:0000 in my timezone (Central).

What time zone is the Python program set to?

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:


#2

On your machine it will be local time. On a website it may be the timezone of the server, or possibly UTC. The time you have displayed there is UTC. CDT is z-5:00 hours.