Time zone


#1

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

https://www.codecademy.com/en/courses/learn-python/lessons/date-and-time/exercises/grand-finale?action=lesson_resume&link_content_target=interstitial_lesson

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)



#2

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.


#3

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