Code:-
let addedTime = dictMessage?.object(forKey: "added_time") as? String
let timeinterval : TimeInterval = (addedTime as NSString).doubleValu
let dateFromServer = NSDate(timeIntervalSince1970:timeinterval)
let dateFormater : DateFormatter = DateFormatter()
dateFormater.dateFormat = "dd-MMM-yyyy hh:mm a"
cellDetailsShop.lblTimeShop?.text = dateFormater.string(from: dateFromServer as Date)
I have a json and from json i m getting Timestamp
which i already converted to Date.Date which i am receiving it is showing in the format "dd-MMM-yyyy hh:mm a"
.But i want to show date like if date is of today then it will show :Today 04:55 PM
,if date is of yesterday then i will show like: Yesterday 5 PM
and if before that then it should show as i am retrieving from JSON. I searched various links but could not find the answer.Could someone help me.Thanks in advance.