<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/SystemFormatStyle/DateReference/init(to:allowedFields:maxFieldCount:thresholdField:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17SystemFormatStyleO13DateReferenceV2to13allowedFields13maxFieldCount09thresholdL0AE10Foundation0F0V_ShyAL010ComponentsdE0V0L0VGSiAPtcfc"
  },
  "title" : "init(to:allowedFields:maxFieldCount:thresholdField:)"
}
-->

# init(to:allowedFields:maxFieldCount:thresholdField:)

Creates a format style that refers to a comparison date
using natural language.

```
init(to date: Date, allowedFields: Set<Date.RelativeFormatStyle.Field> = [.year, .month, .day, .hour, .minute], maxFieldCount: Int = 2, thresholdField: Date.RelativeFormatStyle.Field = .day)
```

## Parameters

`date`

The date this format references.

`allowedFields`

The units of time that may appear in the
relative representation. The style always includes the
`thresholdField` regardless of this set.

`maxFieldCount`

The maximum number of fields the style
shows in the absolute representation. The style excludes
more significant fields whose value matches the reference
date, making room for less significant ones.

`thresholdField`

The time unit that tells the style when
to switch from relative to absolute representation. For
example, if you provide `.minute` and the time difference
extends to hours or days, the style switches from
relative to absolute.

---

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)