<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Date/RelativeFormatStyle/init(presentation:unitsStyle:locale:calendar:capitalizationContext:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation4DateV19RelativeFormatStyleV12presentation05unitsE06locale8calendar21capitalizationContextA2E12PresentationV_AE05UnitsE0VAA6LocaleVAA8CalendarVAA0de14CapitalizationK0Vtcfc"
  },
  "title" : "init(presentation:unitsStyle:locale:calendar:capitalizationContext:)"
}
-->

# init(presentation:unitsStyle:locale:calendar:capitalizationContext:)

Creates a relative date format style with the specified presentation, units, locale, calendar, and capitalization context.

```
init(presentation: Date.RelativeFormatStyle.Presentation = .numeric, unitsStyle: Date.RelativeFormatStyle.UnitsStyle = .wide, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, capitalizationContext: FormatStyleCapitalizationContext = .unknown)
```

## Parameters

`presentation`

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

`unitsStyle`

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

`locale`

The locale to use when formatting the relative date.

`calendar`

The calendar to use when formatting the relative date.

`capitalizationContext`

The capitalization context to use when formatting the relative date.

## Discussion

The following example creates a format style applied to a relative date to create a string representation.

```swift
if let past = Calendar.current.date(byAdding: .day, value: -7, to: Date()) {

    let formatStyle = Date.RelativeFormatStyle(
        presentation: .named,
        unitsStyle: .abbreviated,
        locale: Locale(identifier: "en_US"),
        calendar: Calendar.current,
        capitalizationContext: .beginningOfSentence)
    
    print(past.formatted(formatStyle)) // "Last wk."
}
```

---

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)