How do I get the current Date in short format in Swift
问题 In the images below you can see the code I wrote and the values of all the variables: class fun getCurrentShortDate() -> String { var todaysDate = NSDate() var dateFormatter = NSDateFormatter() dateFormatter.dateFormat = \"dd-MM-yyyy\" var DateInFormat = dateFormatter.stringFromDate(todaysDate) return DateInFormat } Variable values As you can see the current date is found no problem, but when I try to change the NSDate to a string, it just won\'t do it. 回答1: Xcode 8 or later • Swift 3 or