I'm looking to call a function that checks time elapsed since date. This will determine how the timeLable displays in my messages view controller, similar to IMessage.
The code I'm using below only shows HH:MM
let date = dateFormatter().dateFromString((recent["date"] as? String)!)
timeLabel.text = NSDateFormatter.localizedStringFromDate(date!, dateStyle: NSDateFormatterStyle.NoStyle, timeStyle: NSDateFormatterStyle.NoStyle)
I'm looking to change it to something along the lines of:
- If date is today, date = "HH:MM"
- If date is Yesterday, date = "Yesterday"
- If date is the day before yesterday and so on, date = "Monday, Tuesday, Wednesday..."
- If date is over 1 week, date = MM/DD/YY