You can format a date in Swift using DateFormatter
class. Here's how to format a date in the desired format:
main.swift365 chars11 lines
In the above example, dateFormatterGet
is used to convert a string formatted date into a Date
object. Then, dateFormatterPrint
is used to format the date into the desired format.
The output of the code above would be: Aug 12,2019 10:31 PM
.
gistlibby LogSnag