date(from:)
Returns a date representation of a specified string that the system interprets using the receiver’s current settings.
Declaration
func date(from string: String) -> Date?Parameters
- string:
The string to parse.
Return Value
A date representation of string. If date(from:) can’t parse the string, returns nil.
Discussion
For more information about using DateFormatter to convert a string to a date, see Working With Fixed Format Date Representations. For a sample code playground, see Displaying Human-Friendly Content.