I have been searching for a while and haven't found a good answer for this. I currently have when a user posts a photo, it takes an nsdate(timeIntervalSince1970) and puts it as a value when uploaded to firebase. One problem, the current way I change the nsdate to a timeStamp or mins/hours/days since it was posted is not Turing out to good, it does not correct to when a day passes, it just shows what time it was posted at. I was hoping I could get an answer or referred to an algorithm that can change an nsdate(timeIntervalSince1970) to a timeStamp or string that just gives me how many hours ago it was posted, and every 24 hours, change it to 1 day(s). I apologize ahead of time for asking kinda of easy question, I'm guessing. Here is my current code:
if let seconds = posts[visibli.row].timeStamp {
let time = NSDate(timeIntervalSince1970: TimeInterval(seconds))
let formatter = DateFormatter()
formatter.dateFormat = "hh:mm a"
labelTime.text = formatter.string(from: time as Date)
}
Thank you for any Help!
NSDate. Just useDate. - rmaddy