You can use DateFormatter to format dates in Swift.
Here's an example of how to format a date to the desired format:
main.swift285 chars6 linesIn the above code, we first create a variable date that holds the current date and time. Then we create an instance of DateFormatter and set its dateFormat property to the desired format string "MMMM dd, yyyy h:mm a". Finally, we call the string(from: date) method of the dateFormatter instance to get the formatted string. This string is then printed to the console.
gistlibby LogSnag