You can format a date into the desired format using DateFormatter
class in Swift. Here's an example:
main.swift249 chars5 lines
In the above code, we first create an instance of DateFormatter
class and set its dateFormat
property to the desired format. Then, we convert the input string to a Date
object using the date(from:)
method of DateFormatter
. Finally, we convert the date back to a string using the string(from:)
method of DateFormatter
with the same format as before. This gives us the desired output "October 13, 2014 11:13:00.000 AM".
gistlibby LogSnag