I have this code where I\'m trying to get the current date and format it in the current locale.
NSDate *now = [NSDate date]; // gets current date NSString *sNo
Here's a Swift 5 version of @JiaYou's answer:
func format(date: Date) -> String { let formatter = DateFormatter() formatter.dateStyle = .medium formatter.timeStyle = .none return formatter.string(from: date) }
Here I need date only, so I indicate the timeStyle as none.
timeStyle
none