Question

Using GEA and trying to set the time-zone for the DateTimeProperty below. I would like to set the timezone in the model class and not when creating the entry.

class Person(ndb.Model):
    date_created = ndb.DateTimeProperty(auto_now_add=True) 
Was it helpful?

Solution

You are not setting the timezone, you are setting the datetime, when you create the entity. The timezone you would like should stored seperately. All appengine datetime functionality works as UTC.

YOu should convert to UTC when performing queries, and to the timezone you want when displaying content.

OTHER TIPS

The datastore does not store timezones (see the documentation): all datetimes are naive. You need to be sure to always convert times to and from UTC when saving and loading data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top