O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSDate — Mac OS X 10.0

Synopsis

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 calendar—that is, days, weeks, months, years, and so on—the 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.

image with no caption

@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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required