Вопрос

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