Time zone


The hour in now.hour is creating a time four hours ahead


it is producing 18:00 hours

it should be producing 14:00 hours how do I change the time zone so it shows up correctly?

from datetime import datetime
now = datetime.now()

print '%s-%s-%s-%s-%s-%s' % (now.year, now.month, now.day, now.hour, now.minute, now.second)


In the lesson this is the time that prints…

10/29/2017 20:37:32

In my own interactive console it prints this…

>>> from datetime import datetime
>>> now = datetime.now()
>>> print ('%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second))
10/29/2017 14:37:38

We are -6:00 UTC, so from that I conclude that this site is set to UTC time.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.