You can use DateFormatter
to format a date into a string with the desired format. Here's an example code snippet:
main.swift221 chars5 lines
In the above code, we create a DateFormatter
object and set its dateFormat
property to "MMMM d, yyyy" which represents the desired date format. We then create a Date
object with the desired date (here we're using the Unix timestamp for October 13, 2014) and use the dateFormatter
to convert the Date
object into a string representation of the date in the desired format. The resulting dateString
will contain the string "October 13, 2014".
gistlibby LogSnag