<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/RelativeDateTimeFormatter/localizedString(for:relativeTo:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRelativeDateTimeFormatter(im)localizedStringForDate:relativeToDate:"
  },
  "title" : "localizedString(for:relativeTo:)"
}
-->

# localizedString(for:relativeTo:)

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

```
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

A string that represents the date interval between two dates.

## Discussion

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)