<!--
{
  "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(fromTimeInterval:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRelativeDateTimeFormatter(im)localizedStringFromTimeInterval:"
  },
  "title" : "localizedString(fromTimeInterval:)"
}
-->

# localizedString(fromTimeInterval:)

Formats the specified time interval using the formatter’s calendar.

```
func localizedString(fromTimeInterval timeInterval: TimeInterval) -> String
```

## Parameters

`timeInterval`

The time interval to format.

## Return Value

A string that represents the formatted time interval.

## Discussion

The formatter interprets a negative time interval as a date in the past.

```swift
let formatter = RelativeDateTimeFormatter()
print(formatter.localizedString(fromTimeInterval: -120))
// Outputs:  2 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)