---
title: DateIntervalFormatter
framework: foundation
role: symbol
role_heading: Class
path: foundation/dateintervalformatter
---

# DateIntervalFormatter

A formatter that creates string representations of time intervals.

## Declaration

```swift
class DateIntervalFormatter
```

## Overview

Overview A DateIntervalFormatter object creates user-readable strings from pairs of dates. Use a date interval formatter to create user-readable strings of the form <start> - <end> for your app’s interface, where <start> and <end> are date values that you supply. The formatter uses locale and language information, along with custom formatting options, to define the content of the resulting string. You can specify different styles for the date and time information in each date value. To use this class, create an instance, configure its properties, and call the string(from:to:) method to generate a string. The properties of this class let you configure the calendar and specify the style to apply to date and time values. Given a current date of January 16, 2015, Configuring the Formatter Options shows how to configure a formatter object and generate the string “1/16/15 - 1/17/15”. Configuring a formatter object note: Always set to the dateStyle and timeStyle properties to appropriate values before generating any strings. The string(from:to:) method may be called safely from any thread of your app. It is also safe to share a single instance of this class from multiple threads, with the caveat that you should not change the configuration of the object while another thread is using it to generate a string. tip: In Swift, you can use Date.IntervalFormatStyle rather than DateIntervalFormatter. The FormatStyle API offers a declarative idiom for customizing the formatting of various types. Also, Foundation caches identical FormatStyle instances, so you don’t need to pass them around your app, or risk wasting memory with duplicate formatters.

## Topics

### Formatting a String

- [string(from:to:)](foundation/dateintervalformatter/string(from:to:).md)

### Configuring the Formatter Options

- [dateStyle](foundation/dateintervalformatter/datestyle.md)
- [timeStyle](foundation/dateintervalformatter/timestyle.md)
- [dateTemplate](foundation/dateintervalformatter/datetemplate.md)
- [calendar](foundation/dateintervalformatter/calendar.md)
- [locale](foundation/dateintervalformatter/locale.md)
- [timeZone](foundation/dateintervalformatter/timezone.md)

### Constants

- [DateIntervalFormatter.Style](foundation/dateintervalformatter/style.md)

### Instance Methods

- [string(from:)](foundation/dateintervalformatter/string(from:).md)

## Relationships

### Inherits From

- [Formatter](foundation/formatter.md)

### Conforms To

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

## See Also

### Dates and times

- [DateFormatter](foundation/dateformatter.md)
- [DateComponentsFormatter](foundation/datecomponentsformatter.md)
- [RelativeDateTimeFormatter](foundation/relativedatetimeformatter.md)
- [ISO8601DateFormatter](foundation/iso8601dateformatter.md)
