Skip to main content

Working on formatting the date in Xcode, and you come across the situation where you need to check or test the date format.  NSDateFormatter is a great site to check your date format string.  I wanted to transform the 2019-08-15 10:34:49+1000 to Aug 15, 12:34 AM.

let dateFormatter = DateFormatter()

dateFormatter.dateFormat = "MMM d, h:mm a"

let dateFormatted = dateFormatter.string(from: run.timestamp!)

dateFormatted prints Aug 15, 12:34 AM