---
title: NSDateInterval
framework: foundation
role: symbol
role_heading: Class
path: foundation/nsdateinterval
---

# NSDateInterval

An object representing the span of time between a specific start date and end date.

## Declaration

```swift
class NSDateInterval
```

## Overview

Overview In Swift, this object bridges to DateInterval; use NSDateInterval when you need reference semantics or other Foundation-specific behavior. An NSDateInterval object represents a closed interval between two dates. The NSDateInterval class provides a programmatic interface for calculating the duration of a time interval and determining whether a date falls within it, as well as comparing date intervals and checking to see whether they intersect. An NSDateInterval object consists of a startDate and an endDate. The startDate and endDate of a date interval can be equal, in which case its duration is 0. However, endDate cannot occur earlier than startDate. You can use the DateIntervalFormatter class to create string representations of NSDateInterval objects that are suitable for display in the current locale. important: The Swift overlay to the Foundation framework provides the DateInterval structure, which bridges to the NSDateInterval class. For more information about value types, see Working with Foundation Types.

## Topics

### Creating Date Intervals

- [init()](foundation/nsdateinterval/init().md)
- [init(start:duration:)](foundation/nsdateinterval/init(start:duration:).md)
- [init(start:end:)](foundation/nsdateinterval/init(start:end:).md)
- [init(coder:)](foundation/nsdateinterval/init(coder:).md)

### Accessing Start Date, End Date, and Duration

- [startDate](foundation/nsdateinterval/startdate.md)
- [endDate](foundation/nsdateinterval/enddate.md)
- [duration](foundation/nsdateinterval/duration.md)

### Comparing Date Intervals

- [compare(_:)](foundation/nsdateinterval/compare(_:).md)
- [isEqual(to:)](foundation/nsdateinterval/isequal(to:).md)

### Determining Intersections

- [intersects(_:)](foundation/nsdateinterval/intersects(_:).md)
- [intersection(with:)](foundation/nsdateinterval/intersection(with:).md)

### Determining Whether a Date Occurs Within a Date Interval

- [contains(_:)](foundation/nsdateinterval/contains(_:).md)

### Initializers

- [init(startDate:duration:)](foundation/nsdateinterval/init(startdate:duration:).md)
- [init(startDate:endDate:)](foundation/nsdateinterval/init(startdate:enddate:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

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