NSDate Mac OS X 10.0

This class represents a date and time as the number of seconds since the absolute reference date, which is defined as midnight, January 1, 2001, GMT. This class allows you to compare dates, compute time intervals between dates, and obtain string representations of the NSDate object. The dates represented by NSDate are not suitable for presentation to human users. NSDateFormatter objects are used by NSCell objects to convert raw dates into human readable representations. If your application requires the ability to work with date information in terms of a calendarthat is, days, weeks, months, years, and so onthe Foundation framework provides the NSDate subclass NSCalendarDate.

NSDate is toll-free bridged with the Core Foundation type CFDate. As such, NSDate objects can be used interchangeably with the CFDate pointer type, CFDateRef.

See the NSCalendarDate class description for more information. Additionally, Chapter 2 provides more detailed information on the use of NSDate.


@interface NSDate : NSObject <NSCoding, NSCopying>
 // Convenience Constructors
   + (id)date;
   + (id)dateWithString:(NSString *)aString;
   + (id)dateWithTimeIntervalSince1970:(NSTimeInterval)secs;
   + (id)dateWithTimeIntervalSinceNow:(NSTimeInterval)secs;
   + (id)dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)secs;
 // Initializers
   - (id)init;
   - (id)initWithString:(NSString *)description;
   - (id)initWithTimeInterval:(NSTimeInterval)secsToBeAdded  sinceDate:(NSDate *)anotherDate;
   - (id)initWithTimeIntervalSinceNow:(NSTimeInterval)secsToBeAddedToNow;
   - (id)initWithTimeIntervalSinceReferenceDate:(NSTimeInterval)secsToBeAdded;
 // Class Methods
   + (id)distantFuture;
   + (id)distantPast;
   + (id) dateWithNaturalLanguageString:(NSString *)string;
   + (id) dateWithNaturalLanguageString:(NSString *)string locale:(NSDictionary *)dict;
   + (NSTimeInterval)timeIntervalSinceReferenceDate;
 // Instance Methods
   - (id)addTimeInterval:(NSTimeInterval)seconds;
   - (NSComparisonResult)compare:(NSDate *)other;
   - (NSCalendarDate *)dateWithCalendarFormat:(NSString *)format timeZone:(NSTimeZone *)aTimeZone;
   - (NSString *)description;
   - (NSString *)descriptionWithCalendarFormat:(NSString *)format timeZone:(NSTimeZone *)aTimeZone
        locale:(NSDictionary *)locale;
   - (NSString *)descriptionWithLocale:(NSDictionary *)locale;
   - (NSDate *)earlierDate:(NSDate *)anotherDate;
   - (BOOL)isEqualToDate:(NSDate *)otherDate;
   - (NSDate *)laterDate:(NSDate *)anotherDate;
   - (NSTimeInterval)timeIntervalSince1970;
   - (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate;
   - (NSTimeInterval)timeIntervalSinceNow;
   - (NSTimeInterval)timeIntervalSinceReferenceDate;
 // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
 // Methods Implementing NSCopying
   - (id)copyWithZone:(NSZone *)zone;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes