---
title: unitsStyle
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/date/relativeformatstyle/unitsstyle-swift.property
---

# unitsStyle

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

## Declaration

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

## Discussion

Discussion Express relative date format units in either wide, narrow, abbreviated, or spellOut styles. For example: 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" }

## See Also

### Modifying a Relative Date Format Style

- [presentation](foundation/date/relativeformatstyle/presentation-swift.property.md)
- [calendar](foundation/date/relativeformatstyle/calendar.md)
- [capitalizationContext](foundation/date/relativeformatstyle/capitalizationcontext.md)
- [locale](foundation/date/relativeformatstyle/locale.md)
- [locale(_:)](foundation/date/relativeformatstyle/locale(_:).md)
