<!--
{
  "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",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17SystemFormatStyleO13DateReferenceV"
  },
  "title" : "SystemFormatStyle.DateReference"
}
-->

# SystemFormatStyle.DateReference

A format style that refers to a date using the most natural
phrasing based on how much time separates it from the current time.

```
struct DateReference
```

## Overview

`DateReference` adapts its output based on how far the
referenced date is from the input (which is typically the
current time). Close dates use a relative representation,
while distant dates switch to an absolute one.

```swift
// Displays "in 5 minutes", "tomorrow", "June 2019", etc.
Text(.currentDate, format: .reference(to: eventDate))
```

### Relative vs. absolute representation

The style uses a relative format (“in 2 hours”, “3 days ago”)
when the referenced date is within the threshold distance.
Beyond that threshold, it switches to an absolute format
(“Monday, June 3”, “June 2019”).

The `thresholdField` parameter controls where this switch
happens. With the default value of `.day`, the style uses
the relative format as long as the date falls within
approximately one month of the reference date:

|Distance |Style   |Output          |
|---------|--------|----------------|
|< 1 min  |Relative|`now`           |
|5 min    |Relative|`in 5 minutes`  |
|3 hours  |Relative|`in 3 hours`    |
|1 day    |Relative|`tomorrow`      |
|3 days   |Relative|`3 days ago`    |
|27 days  |Relative|`27 days ago`   |
|> 1 month|Absolute|`Monday, June 3`|
|> 1 year |Absolute|`June 2019`     |

### Controlling the absolute representation

The `maxFieldCount` parameter determines how many date
components appear in the absolute representation:

```swift
// maxFieldCount: 2 (default)
// Output for a date in a different year: "June 2019"

// maxFieldCount: 3
.reference(to: date, maxFieldCount: 3)
// Output: "June 3, 2019"
```

The style automatically removes higher-order fields that
match the reference date. For a date within the same year,
the year field is dropped, leaving room for day-level detail:

```swift
// Same year as reference date, maxFieldCount: 2
// Output: "Monday, June 3" (instead of "June 2019")
```

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`FormatStyle`](/documentation/Foundation/FormatStyle)

[`Equatable`](/documentation/Swift/Equatable)

[`Copyable`](/documentation/Swift/Copyable)

[`Decodable`](/documentation/Swift/Decodable)

[`DiscreteFormatStyle`](/documentation/Foundation/DiscreteFormatStyle)

[`Escapable`](/documentation/Swift/Escapable)

[`Encodable`](/documentation/Swift/Encodable)

[`Hashable`](/documentation/Swift/Hashable)

---

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)