<!--
{
  "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",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRelativeDateTimeFormatter"
  },
  "title" : "RelativeDateTimeFormatter"
}
-->

# RelativeDateTimeFormatter

A formatter that creates locale-aware string representations of a relative date or time.

```
class RelativeDateTimeFormatter
```

## Overview

Use the strings that the formatter produces, such as “1 hour ago”, “in 2 weeks”, “yesterday”, and “tomorrow” as standalone strings. Embedding them in other strings may not be grammatically correct.

## Topics

### Converting Dates to Formatted Strings

[`localizedString(for:relativeTo:)`](/documentation/Foundation/RelativeDateTimeFormatter/localizedString(for:relativeTo:))

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

[`localizedString(from:)`](/documentation/Foundation/RelativeDateTimeFormatter/localizedString(from:))

Formats a relative time represented by the specified date components.

[`localizedString(fromTimeInterval:)`](/documentation/Foundation/RelativeDateTimeFormatter/localizedString(fromTimeInterval:))

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

[`string(for:)`](/documentation/Foundation/RelativeDateTimeFormatter/string(for:))

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

### Configuring Formatter Options

[`calendar`](/documentation/Foundation/RelativeDateTimeFormatter/calendar)

The calendar to use for formatting values that don’t have an inherent calendar of their own.

[`locale`](/documentation/Foundation/RelativeDateTimeFormatter/locale)

The locale to use when formatting the date.

[`dateTimeStyle`](/documentation/Foundation/RelativeDateTimeFormatter/dateTimeStyle-swift.property)

The style to use when describing a relative date, for example “yesterday” or “1 day ago”.

[`RelativeDateTimeFormatter.DateTimeStyle`](/documentation/Foundation/RelativeDateTimeFormatter/DateTimeStyle-swift.enum)

A type that represents the style to use when formatting relative dates, such as “1 week ago” or “last week”.

[`unitsStyle`](/documentation/Foundation/RelativeDateTimeFormatter/unitsStyle-swift.property)

The style to use when formatting the quantity or the name of the unit, such as “1 day ago” or “one day ago”.

[`RelativeDateTimeFormatter.UnitsStyle`](/documentation/Foundation/RelativeDateTimeFormatter/UnitsStyle-swift.enum)

A type that represents the style to use when formatting the units of relative dates.

[`formattingContext`](/documentation/Foundation/RelativeDateTimeFormatter/formattingContext)

A description of where the formatted string will appear, allowing the formatter to capitalize the output appropriately.



---

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)