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) 
有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top