In the images below you can see the code I wrote and the values of all the variables:
class fun getCurrentShortDate() -> String { var todaysDate = NSD
SWIFT 4 or 5
extension Date { static func getCurrentDate() -> String { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "dd/MM/yyyy HH:mm:ss" return dateFormatter.string(from: Date()) } }
Using
print(Date.getCurrentDate())