---
title: "string(for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/relativedatetimeformatter/string(for:)"
---

# string(for:)

Creates a formatted string for a date relative to the current date and time.

## Declaration

```swift
func string(for obj: Any?) -> String?
```

## Parameters

- `obj`: A date object to format.

## Return Value

Return Value A string that represents the date interval between a date and the current date and time, or nil if obj isn’t an instance of NSDate.

## Discussion

Discussion To determine the relative interval, the formatter uses date as the reference date.

## See Also

### Converting Dates to Formatted Strings

- [localizedString(for:relativeTo:)](foundation/relativedatetimeformatter/localizedstring(for:relativeto:).md)
- [localizedString(from:)](foundation/relativedatetimeformatter/localizedstring(from:).md)
- [localizedString(fromTimeInterval:)](foundation/relativedatetimeformatter/localizedstring(fromtimeinterval:).md)
