I have datastore Model bellow:
class ThisCategory(search.SearchableModel):
anc开发者_JAVA技巧estor = db.ListProperty(db.Key, default=[])
no_ancestor = db.BooleanProperty(default=True)
name = db.StringProperty()
description = db.TextProperty()
last_modified = db.TimeProperty(auto_now=True) #<----- (1970-01-01 15:36:47.987352) in datastore
How to create/result correct now date?
A TimeProperty
is just a DateTime
object with the date part set to 0 (which means 1970-01-01).
The idea is that when you use a TimeProperty
you ignore the date part.
If you want to use the Date information too, then you want a DateTimeProperty
. The DateTimeProperty
's auto_now will properly set both the date and time parts.
精彩评论