---
title: "localizedString(for:relativeTo:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/relativedatetimeformatter/localizedstring(for:relativeto:)"
---

# localizedString(for:relativeTo:)

Formats the date interval from the reference date to the specified date using the formatter’s calendar.

## Declaration

```swift
func localizedString(for date: Date, relativeTo referenceDate: Date) -> String
```

## Parameters

- `date`: The end date of the interval to format.
- `referenceDate`: The start date of the interval to format.

## Return Value

Return Value A string that represents the date interval between two dates.

## Discussion

Discussion let tenMinutesAgo = Date(timeIntervalSinceNow: -600) let twoMintuesAhead = Date(timeIntervalSinceNow: 120) let formatter = RelativeDateTimeFormatter() print(formatter.localizedString(for: tenMinutesAgo, relativeTo: twoMintuesAhead)) // Outputs: 12 minutes ago

## See Also

### Converting Dates to Formatted Strings

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