Ivan Slaughter
Ivan Slaughter

Reputation: 767

GAE datastore date property auto produce date of 1970

I have datastore Model bellow:

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

How to create/result correct now date?

Upvotes: 0

Views: 299

Answers (1)

wm_eddie
wm_eddie

Reputation: 3958

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.

Upvotes: 6

Related Questions