<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSDate",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDate"
  },
  "title" : "NSDate"
}
-->

# NSDate

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

```
class NSDate
```

## Overview

In Swift, use this type when you need reference semantics or other Foundation-specific behavior.

[`NSDate`](/documentation/Foundation/NSDate) objects encapsulate a single point in time, independent of any particular calendrical system or time zone. Date objects are immutable, representing an invariant time interval relative to an absolute reference date (00:00:00 UTC on 1 January 2001).

The [`NSDate`](/documentation/Foundation/NSDate) class provides methods for comparing dates, calculating the time interval between two dates, and creating a new date from a time interval relative to another date. [`NSDate`](/documentation/Foundation/NSDate) objects can be used in conjunction with [`DateFormatter`](/documentation/Foundation/DateFormatter) objects to create localized representations of dates and times, as well as with [`NSCalendar`](/documentation/Foundation/NSCalendar) objects to perform calendar arithmetic.

[`NSDate`](/documentation/Foundation/NSDate) is *toll-free bridged* with its Core Foundation counterpart, <doc://com.apple.documentation/documentation/CoreFoundation/CFDate>. See [Toll-Free Bridging](https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/Toll-FreeBridgin/Toll-FreeBridgin.html#//apple_ref/doc/uid/TP40010810-CH2) for more information on toll-free bridging.

> Important:
> The Swift overlay to the Foundation framework provides the ``doc://com.apple.foundation/documentation/Foundation/Date`` structure, which bridges to the ``doc://com.apple.foundation/documentation/Foundation/NSDate`` class. For more information about value types, see <doc://com.apple.documentation/documentation/Swift/working-with-foundation-types>.

### Subclassing Notes

You might subclass [`NSDate`](/documentation/Foundation/NSDate) in order to make it easier to work with a particular calendrical system, or to work with date and time values with a finer temporal granularity.

#### Methods to Override and Other Requirements

If you want to subclass [`NSDate`](/documentation/Foundation/NSDate) to obtain behavior different than that provided by the private or public subclasses, you must:

- Declare a suitable instance variable to hold the date and time value (relative to an absolute reference date)
- Override the [`timeIntervalSinceReferenceDate`](/documentation/Foundation/NSDate/timeIntervalSinceReferenceDate-swift.property) instance method to provide the correct date and time value based on your instance variable
- Override [`init(timeIntervalSinceReferenceDate:)`](/documentation/Foundation/NSDate/init(timeIntervalSinceReferenceDate:)), one of the designated initializer methods
- If creating a subclass that represents a calendrical system, define methods that partition past and future periods into the units of this calendar
- Implement the methods required by the [`NSCopying`](/documentation/Foundation/NSCopying) and [NSCoding](https://developer.apple.com/library/archive/documentation/Swift/Conceptual/BuildingCocoaApps/WritingSwiftClassesWithObjective-CBehavior.html#//apple_ref/doc/uid/TP40014216-CH5-ID152) protocols, because [`NSDate`](/documentation/Foundation/NSDate) adopts these protocols

#### Special Considerations

Your subclass may use a different reference date than the absolute reference date used by [`NSDate`](/documentation/Foundation/NSDate) (00:00:00 UTC on 1 January 2001). If it does, it must still use the absolute reference date in its implementations of the methods [`timeIntervalSinceReferenceDate`](/documentation/Foundation/NSDate/timeIntervalSinceReferenceDate-swift.property) and [`init(timeIntervalSinceReferenceDate:)`](/documentation/Foundation/NSDate/init(timeIntervalSinceReferenceDate:)). That is, the reference date referred to in the titles of these methods is the absolute reference date. If you do not use the absolute reference date in these methods, comparisons between [`NSDate`](/documentation/Foundation/NSDate) objects of your subclass and `NSDate` objects of a private subclass will not work.

## Topics

### Creating a Date

[`date`](/documentation/Foundation/NSDate/date)

Creates and returns a new date object set to the current date and time.

[`dateWithTimeIntervalSinceNow:`](/documentation/Foundation/NSDate/dateWithTimeIntervalSinceNow:)

Creates and returns a date object set to a given number of seconds from the current date and time.

[`dateWithTimeIntervalSinceReferenceDate:`](/documentation/Foundation/NSDate/dateWithTimeIntervalSinceReferenceDate:)

Creates and returns a date object set to a given number of seconds from 00:00:00 UTC on 1 January 2001.

[`dateWithTimeIntervalSince1970:`](/documentation/Foundation/NSDate/dateWithTimeIntervalSince1970:)

Creates and returns a date object set to the given number of seconds from 00:00:00 UTC on 1 January 1970.

### Initializing a Date

[`init()`](/documentation/Foundation/NSDate/init())

Returns a date object initialized to the current date and time.

[`init(timeIntervalSinceNow:)`](/documentation/Foundation/NSDate/init(timeIntervalSinceNow:))

Returns a date object initialized relative to the current date and time by a given number of seconds.

[`init(timeIntervalSinceReferenceDate:)`](/documentation/Foundation/NSDate/init(timeIntervalSinceReferenceDate:))

Returns a date object initialized relative to 00:00:00 UTC on 1 January 2001 by a given number of seconds.

[`init(timeIntervalSince1970:)`](/documentation/Foundation/NSDate/init(timeIntervalSince1970:))

Returns a date object initialized relative to 00:00:00 UTC on 1 January 1970 by a given number of seconds.

[`init(coder:)`](/documentation/Foundation/NSDate/init(coder:))

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

### Getting Temporal Boundaries

[`distantFuture`](/documentation/Foundation/NSDate/distantFuture)

A date object representing a date in the distant future.

[`distantPast`](/documentation/Foundation/NSDate/distantPast)

A date object representing a date in the distant past.

### Retrieving the Current Date

[`now`](/documentation/Foundation/NSDate/now)

The current date and time, as of the time of access.

### Comparing Dates

[`isEqual(to:)`](/documentation/Foundation/NSDate/isEqual(to:))

Returns a Boolean value that indicates whether a given object is a date that is exactly equal the receiver.

[`earlierDate(_:)`](/documentation/Foundation/NSDate/earlierDate(_:))

Returns the earlier of the receiver and another given date.

[`laterDate(_:)`](/documentation/Foundation/NSDate/laterDate(_:))

Returns the later of the receiver and another given date.

[`compare(_:)`](/documentation/Foundation/NSDate/compare(_:))

Indicates the temporal ordering of the receiver and another given date.

### Getting Time Intervals

[`timeIntervalSince(_:)`](/documentation/Foundation/NSDate/timeIntervalSince(_:))

Returns the interval between the receiver and another given date.

[`timeIntervalSinceNow`](/documentation/Foundation/NSDate/timeIntervalSinceNow)

The interval between the date object and the current date and time.

[`timeIntervalSinceReferenceDate`](/documentation/Foundation/NSDate/timeIntervalSinceReferenceDate-swift.property)

The interval between the date object and 00:00:00 UTC on 1 January 2001.

[`timeIntervalSince1970`](/documentation/Foundation/NSDate/timeIntervalSince1970)

The interval between the date object and 00:00:00 UTC on 1 January 1970.

[`timeIntervalSinceReferenceDate`](/documentation/Foundation/NSDate/timeIntervalSinceReferenceDate-swift.type.property)

The interval between 00:00:00 UTC on 1 January 2001 and the current date and time.

[`NSTimeIntervalSince1970`](/documentation/Foundation/NSTimeIntervalSince1970)

The number of seconds from 1 January 1970 to the reference date, 1 January 2001.

### Adding Time Intervals

[`addingTimeInterval(_:)`](/documentation/Foundation/NSDate/addingTimeInterval(_:))

Returns a new date object that is set to a given number of seconds relative to the receiver.

### Describing Dates

[`description`](/documentation/Foundation/NSDate/description)

A string representation of the date object.

[`description(with:)`](/documentation/Foundation/NSDate/description(with:))

Returns a string representation of the date using the given locale.

[`customPlaygroundQuickLook`](/documentation/Foundation/NSDate/customPlaygroundQuickLook)

A custom playground Quick Look for this object.

### Recognizing Notifications

[`NSSystemClockDidChange`](/documentation/Foundation/NSNotification/Name-swift.struct/NSSystemClockDidChange)

A notification posted whenever the system clock is changed.

### Legacy Operations

[`date(withNaturalLanguageString:)`](/documentation/Foundation/NSDate/date(withNaturalLanguageString:))

Creates and returns a date object set to the date and time specified by a given string.

[`date(withNaturalLanguageString:locale:)`](/documentation/Foundation/NSDate/date(withNaturalLanguageString:locale:))

Creates and returns a date object set to the date and time specified by a given string.

[`date(with:)`](/documentation/Foundation/NSDate/date(with:))

Creates and returns a date object with a date and time value specified by a given string in the international string representation format (`YYYY-MM-DD HH:MM:SS ±HHMM`).

[`init(string:)`](/documentation/Foundation/NSDate/init(string:))

Returns a date object initialized with a date and time value specified by a given string in the international string representation format.

[`addTimeInterval(_:)`](/documentation/Foundation/NSDate/addTimeInterval(_:))

Returns a new date object that is set to a given number of seconds relative to the receiver.

[`date(withCalendarFormat:timeZone:)`](/documentation/Foundation/NSDate/date(withCalendarFormat:timeZone:))

Converts the receiver to a calendar date with a given format string and time zone.

[`description(withCalendarFormat:timeZone:locale:)`](/documentation/Foundation/NSDate/description(withCalendarFormat:timeZone:locale:))

Returns a string representation of the date formatted as specified by given conversion specifiers.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)