You can format a date object into the desired string format using a DateFormatter object in Swift. Here's an example code snippet to format a date into the format "October 13, 2014 11:13:00 AM":
main.swift255 chars6 linesOutput:
main.swift51 chars2 lines
In the dateFormat property of the DateFormatter, we have specified the format string using various symbols representing the components of the date and time.
MMMM: Full name of the monthd: Day of the month (no leading zeros)yyyy: 4-digit yearh: Hour in 12-hour format (no leading zeros)mm: Minute (with leading zeros)ss: Second (with leading zeros)a: AM/PM indicatorNote that we used MMMM instead of MM for the month symbol to get the full name of the month.
gistlibby LogSnag