Convert string with unknown format (any format) to date
I have data that contains a date string. Normally it would be in a 'Jan. 3, 1966' type format, but because of international differences, it may not always be exactly that. I need to read the data in and convert it into a standard date string ('YYYY-MM-DD'). Basically this is what I have so far: var dataString = 'Jan. 3, 1966' var dateFormatter = NSDateFormatter() dateFormatter.dateFormat = # I DON'T KNOW THE EXACT INPUT FORMAT ! let dateValue = dateFormatter.dateFromString(dataString) Xcode 9 • Swift 4 or Xcode 8.3.2 • Swift 3.1 You can use NSDataDetector as follow: extension String { var