The question seems easy bit it is a bit more complicated. Here is the relevant database structure:
"people" : {
"q3up6CyAe5PoEAooJwCclOGGcZd2" : {
"peopleWhoLike2" : {
"NMNQYJ5z64fATK2MMs7m0ggHl0k2" : 1571089433551
We are interested in the 1571089433551 timestamp. The first user id (q3up6CyAe5PoEAooJwCclOGGcZd2) is the user whom the current user liked. The current user is NMNQYJ5z64fATK2MMs7m0ggHl0k2
We want to write an if statement for when the current time minus 1571089433551 is larger than 8000 seconds. That part I can do. The question is not for that. It is for how to get to 1571089433551 as an int via a snapshot
This is how the timestamp was made:
ref.child("people").child(self.postID).observeSingleEvent(of: .value, with: {(snapshot) in
if let people1 = snapshot.value as? [String: AnyObject] {
let current = Auth.auth().currentUser!.uid
let p3 = ServerValue.timestamp()as! [String : Any]
let updateLikes: [String: Any] = [current: p3]
ref.child("people").child(self.postID).child("peopleWhoLike2").updateChildValues(updateLikes, withCompletionBlock: { (error, reff) in .....
This is where I tried to user it for the IF statement
let thisUsersUid = Auth.auth().currentUser?.uid //Mr. Dunn's uid
refArtists = Database.database().reference().child("people").child(self.postID).child("peopleWhoLike2")
refArtists.observe(DataEventType.value, with: {snapshot in
---------
let secondsInDay = 86400
if (Int(-date.timeIntervalSinceNow) < secondsInDay){
That ------ part between the above is what I need to figure out. How to read the firebase snapshot and get the 1571089433551 as an int.