---
title: "date(from:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/dateformatter/date(from:)"
---

# date(from:)

Returns a date representation of a specified string that the system interprets using the receiver’s current settings.

## Declaration

```swift
func date(from string: String) -> Date?
```

## Parameters

- `string`: The string to parse.

## Return Value

Return Value A date representation of string. If date(from:) can’t parse the string, returns nil.

## Discussion

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.

## See Also

### Converting Objects

- [string(from:)](foundation/dateformatter/string(from:).md)
- [localizedString(from:dateStyle:timeStyle:)](foundation/dateformatter/localizedstring(from:datestyle:timestyle:).md)
- [getObjectValue(_:for:range:)](foundation/dateformatter/getobjectvalue(_:for:range:).md)
