ios - Query objects newer then 24 hours -
so way snapchat has, show in story images/videos newer 24 hours old. how can same using query code:
func querystory(){ let query = pfquery(classname: "myclass") query.wherekey("ispending", equalto: false) query.limit = 1000 query.orderbydescending("createdat") query.findobjectsinbackgroundwithblock { (posts: [pfobject]?, error: nserror?) -> void in if (error == nil){ // success fetching objects post in posts! { if let imagefile = post["userfile"] as? pffile { self.userfile.append(post["userfile"] as! pffile) self.objid.append(post.objectid!) self.createdat.append(post.createdat!) } } } else{ print(error) } } } }
i tried adding:
var date: nsdate = nsdate(timeintervalsincenow: -172800) query.wherekey("createdat", greaterthan: date)
but gave me 0 items.(my class has total 28 items). ideas?
the correct format 24 hours be:
let date: nsdate = nsdate(timeintervalsincenow: -86400) query.wherekey("createdat", greaterthan: date)
how old files trying query parse?