You can use DateFormatter class to achieve this. Here's an example code:
main.swift209 chars6 linesHere, we are creating an instance of Date using Date() constructor. Then, we are creating another instance of DateFormatter class and setting its dateFormat property to the desired format. Finally, we are using string(from: date) method of the dateFormatter instance to get the formatted date string.
gistlibby LogSnag