Today while coding my first Facebook application running on Google App Engine I was getting odd errors related to time from the datastore.
The problem was that Google App Engine’s time is always running from Coordinated Universal Time (UTC), even when you use something like:
1 2 | import datetime datetime.datetime.now() |
How you should and I have compensate for this is taking the difference of the time you want to UTC time in order to shift the time to the time zone of interest:
1 2 3 4 5 | import datetime time = datetime.datetime.utcnow() - datetime.timedelta(hours = 5) # for East Coast United States time = datetime.datetime.utcnow() - datetime.timedelta(hours = 6) # for Central United States time = datetime.datetime.utcnow() - datetime.timedelta(hours = 7) # for Rocky Mountains United States time = datetime.datetime.utcnow() - datetime.timedelta(hours = 8) # for West Coast United States |
This will give you the correct time in your time zone





thanks, this cleared my headache up!