I am trying to convert passed NSDate into a readable Date/Time String for a UILabel. For some reason the label is showing unexpected dates in the output.
struct myDateRange{
var startDate: NSNumber?
var endDate: NSNumber?
}
func configureDate(date:myDateRange){
let date = NSDate(timeIntervalSince1970: date.startDate as! TimeInterval)
let timeFormat = DateFormatter()
timeFormat.timeStyle = .short
timeFormat.dateStyle = .short
let currentTime = "\(timeFormat.string(from: date as Date))"
timeLabel.text = String(currentTime)
}
Output:
passed: Optional(1518393600000)
labeltext: 12/23/85, 10:30 AM
Expected:
02/12/18, 12:00