2010-08-31 39 views
0

汽車生產日期我有波紋管數據存儲模式:GAE數據存儲日期屬性的1970年

class ThisCategory(search.SearchableModel): 
    ancestor = 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 

如何創建/結果正確,現在的日期?

回答

6

A TimeProperty只是一個DateTime對象,其日期部分設置爲0(表示1970-01-01)。

想法是,當您使用TimeProperty時,您會忽略日期部分。

如果你想使用日期信息,那麼你想要一個DateTimePropertyDateTimeProperty的auto_now將正確設置日期和時間部分。