---
title: CLKRelativeDateTextProvider
framework: clockkit
role: symbol
role_heading: Class
path: clockkit/clkrelativedatetextprovider
---

# CLKRelativeDateTextProvider

A formatted string that conveys the difference in time between the current date and a date that you specify.

## Declaration

```swift
class CLKRelativeDateTextProvider
```

## Mentioned in

Creating a timeline entry

## Overview

Overview You use a relative date text provider to implement timers or other relative time values in an efficient way. Instead of using multiple timeline entries to replicate a countdown timer, create a single timeline entry with a relative date text provider. When the user views the clock face, ClockKit automatically updates the relative time value in your complication, providing up-to-date time information. When creating the formatted string, the relative date text provider creates the longest string that fits in the given space. It includes as many of the requested date elements as it can, but may truncate elements or use abbreviations as needed. The formatted string takes into account the user’s region and locale settings. Date Format Options When creating a CLKRelativeDateTextProvider object, you must specify which calendar units you want included in the resulting date. Only the following calendar units are supported: NSYearCalendarUnit NSMonthCalendarUnit NSWeekOfMonthCalendarUnit NSDayCalendarUnit NSHourCalendarUnit NSMinuteCalendarUnit NSSecondCalendarUnit note: When creating a relative date provider using the CLKRelativeDateStyle.timer style, only the NSHourCalendarUnit, NSMinuteCalendarUnit, and NSSecondCalendarUnit units are supported. All other calendar units are ignored. The format of the relative time value is dependent on the date style you choose when creating the text provider. For a list of possible styles and examples of each, see CLKRelativeDateStyle.

## Topics

### Creating a Text Provider

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

### Getting the Date Information

- [date](clockkit/clkrelativedatetextprovider/date.md)
- [relativeToDate](clockkit/clkrelativedatetextprovider/relativetodate.md)
- [relativeDateStyle](clockkit/clkrelativedatetextprovider/relativedatestyle.md)
- [calendarUnits](clockkit/clkrelativedatetextprovider/calendarunits.md)

### Constants

- [CLKRelativeDateStyle](clockkit/clkrelativedatestyle.md)

### Initializers

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

## Relationships

### Inherits From

- [CLKTextProvider](clockkit/clktextprovider.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Text providers

- [CLKSimpleTextProvider](clockkit/clksimpletextprovider.md)
- [CLKDateTextProvider](clockkit/clkdatetextprovider.md)
- [CLKTimeIntervalTextProvider](clockkit/clktimeintervaltextprovider.md)
- [CLKTimeTextProvider](clockkit/clktimetextprovider.md)
- [CLKTextProvider](clockkit/clktextprovider.md)
