<!--
{
  "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/unitsStyle-swift.property",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation4DateV19RelativeFormatStyleV05unitsE0AE05UnitsE0Vvp"
  },
  "title" : "unitsStyle"
}
-->

# unitsStyle

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

```
var unitsStyle: Date.RelativeFormatStyle.UnitsStyle
```

## Discussion

Express relative date format units in either `wide`, `narrow`, `abbreviated`, or `spellOut` styles. For example:

```swift
if let past = Calendar.current.date(byAdding: .day, value: -14, to: Date()) {
    past.formatted(.relative(presentation: .named, unitsStyle: .wide)) // "2 weeks ago"
    past.formatted(.relative(presentation: .named, unitsStyle: .narrow)) // "2 wk. ago"
    past.formatted(.relative(presentation: .named, unitsStyle: .abbreviated)) // "2 wk. ago"
    past.formatted(.relative(presentation: .named, unitsStyle: .spellOut)) // "two weeks 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)