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


@interface NSDateInterval : NSObject


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 NSDateIntervalFormatter class to create string representations of NSDateInterval objects that are suitable for display in the current locale.


Creating Date Intervals

- init

Initializes a date interval by setting the start and end date to the current date.

- initWithStartDate:duration:

Initializes a date interval with a given start date and duration.

- initWithStartDate:endDate:

Initializes a date interval from a given start date and end date.

- initWithCoder:

Returns a date interval initialized from data in the given unarchiver.

Accessing Start Date, End Date, and Duration


The start date of the date interval.


The end date of the date interval.


The duration of the date interval.

Comparing Date Intervals

- compare:

Compares the receiver with the specified date interval.

- isEqualToDateInterval:

Indicates whether the receiver is equal to the specified date interval.

Determining Intersections

- intersectsDateInterval:

Indicates whether the receiver intersects with the specified date interval.

- intersectionWithDateInterval:

Returns the intersection between the receiver and the specified date interval.

Determining Whether a Date Occurs Within a Date Interval

- containsDate:

Indicates whether the receiver contains the specified date.


Inherits From

See Also

Date Representations


A representation of a specific point in time, independent of any calendar or time zone.


A number of seconds.