Pregunta

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) 
¿Fue útil?

Solución

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.

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top