---
title: "init(date:relativeTo:style:units:)"
framework: clockkit
role: symbol
role_heading: Initializer
path: "clockkit/clkrelativedatetextprovider/init(date:relativeto:style:units:)"
---

# init(date:relativeTo:style:units:)

Creates a text provider that shows the difference in time between the provided dates.

## Declaration

```swift
convenience init(date: Date, relativeTo relativeToDate: Date?, style: CLKRelativeDateStyle, units calendarUnits: NSCalendar.Unit)
```

## Parameters

- `date`: The starting date, used to calculate the relative date string.
- `relativeToDate`: The end date, used to calculate the relative date string.
- `style`: The style to use when formatting the relative date value. For a list of possible values, see doc://com.apple.clockkit/documentation/ClockKit/CLKRelativeDateStyle.
- `calendarUnits`: The units to include in the resulting date string. For a list of supported calendar units, see doc://com.apple.clockkit/documentation/ClockKit/CLKRelativeDateTextProvider#Date-Format-Options.

## Discussion

Discussion This initializer creates a text provider that produces a fixed, relative date. If you want a text provider that automatically updates as time passes, use init(date:style:units:) instead.

## See Also

### Creating a Text Provider

- [init(date:style:units:)](clockkit/clkrelativedatetextprovider/init(date:style:units:).md)
