date(format: String, locale: Locale = .current) -> Date?

Return a date from current string.

Parameters

  • format: The date format
  • locale: The locale. default to .current

Returns

A Date.

"01-01-1970 00:34:22".date(format: "dd/MM/yyyy HH:mm:ss")
// -> 01-01-1970 00:34:22