开发者

GAE datastore date property auto produce date of 1970

开发者 https://www.devze.com 2023-01-14 08:51 出处:网络
I have datastore Model bellow: class ThisCategory(search.SearchableModel): anc开发者_JAVA技巧estor = db.ListProperty(db.Key, default=[])

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号