You can format a date string in Swift using DateFormatter. Here is an example of how to format a date in 'yyyy-mm-dd hh:mm:ss.fff zzz' format:
main.swift210 chars5 linesIn the above example, we first create an instance of DateFormatter and set the date format we want using dateFormat property. We then call the string(from:) method on the formatter instance to get the formatted date string. The from parameter is an instance of Date which is the current date and time by calling the Date() function. Finally, we print the formatted date string.
gistlibby LogSnag