iPhone OS Reference Library Apple Developer Connection spyglass button

NSDateFormatter Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in iPhone OS 2.0 and later.
Companion guide
Declared in
NSDateFormatter.h
Related sample code

Overview

Instances of NSDateFormatter create string representations of NSDate (and NSCalendarDate) objects, and convert textual representations of dates and times into NSDate objects. You can express the representation of dates and times flexibly using pre-set format styles or custom format strings.

In general, you are encouraged to use format styles (see timeStyle, dateStyle, and NSDateFormatterStyle) rather than using custom format strings, since the format for a given style reflects a user’s preferences. Format styles also reflect the locale setting.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
 
NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:118800];
 
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[dateFormatter setLocale:usLocale];
 
NSLog(@"Date for locale %@: %@",
      [[dateFormatter locale] localeIdentifier], [dateFormatter stringFromDate:date]);
// Output:
// Date for locale en_US: Jan 2, 2001
 
NSLocale *frLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"];
[dateFormatter setLocale:frLocale];
NSLog(@"Date for locale %@: %@",
      [[dateFormatter locale] localeIdentifier], [dateFormatter stringFromDate:date]);
// Output:
// Date for locale fr_FR: 2 janv. 2001

Formatter Behaviors and OS Versions

With Mac OS X v10.4 and later, NSDateFormatter has two modes of operation (or behaviors). See Data Formatting Programming Guide for Cocoa for a full description of the old and new behaviors.

iPhone OS Note: iPhone OS supports only the 10.4+ behavior. 10.0-style methods and format strings are not available on iPhone OS.

By default, on Mac OS X v10.4 instances of NSDateFormatter have the same behavior as they did on Mac OS X versions 10.0 to 10.3. On Mac OS X v10.5 and later, NSDateFormatter defaults to the 10.4+ behavior.

If you initialize a formatter using initWithDateFormat:allowNaturalLanguage:, you are (for backwards compatibility reasons) creating an “old-style” date formatter. To use the new behavior, you initialize the formatter with init. If necessary, you can set the default class behavior using setDefaultFormatterBehavior:), you can set the behavior for an instance using setFormatterBehavior: message with the argument NSDateFormatterBehavior10_4.

By default, the 10.4-style formatter returns NSDate objects (prior to Mac OS X v10.4, date formatters returned NSCalendarDate objects). You can change this behavior using setGeneratesCalendarDates:, although this is strongly discouraged (as NSCalendarDate is deprecated on Mac OS X v10.6 and later).

Tasks

Initializing a Date Formatter

Managing Behavior

Converting Objects

Managing Formats and Styles

Managing Attributes

Managing AM and PM Symbols

Managing Weekday Symbols

Managing Month Symbols

Managing Quarter Symbols

Managing Era Symbols

Class Methods

defaultFormatterBehavior

Returns the default formatting behavior for instances of the class.

+ (NSDateFormatterBehavior)defaultFormatterBehavior

Return Value

The default formatting behavior for instances of the class. For possible values, see NSDateFormatterBehavior.

Discussion

The default is NSDateFormatterBehavior10_0.

Availability
See Also
Declared In
NSDateFormatter.h

setDefaultFormatterBehavior:

Sets the default formatting behavior for instances of the class.

+ (void)setDefaultFormatterBehavior:(NSDateFormatterBehavior)behavior

Parameters
behavior

The default formatting behavior for instances of the class. For possible values, see NSDateFormatterBehavior.

Availability
See Also
Declared In
NSDateFormatter.h

Instance Methods

AMSymbol

Returns the AM symbol for the receiver.

- (NSString *)AMSymbol

Return Value

The AM symbol for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

calendar

Returns the calendar for the receiver.

- (NSCalendar *)calendar

Return Value

The calendar for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

dateFormat

Returns the date format string used by the receiver.

- (NSString *)dateFormat

Return Value

The date format string used by the receiver.

Discussion

See Date Format String Syntax (Mac OS X Versions 10.0 to 10.3) for a list of the conversion specifiers permitted in date format strings.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

dateFromString:

Returns a date representation of a given string interpreted using the receiver’s current settings.

- (NSDate *)dateFromString:(NSString *)string

Parameters
string

The string to parse.

Return Value

A date representation of string interpreted using the receiver’s current settings.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

dateStyle

Returns the date style of the receiver.

- (NSDateFormatterStyle)dateStyle

Return Value

The date style of the receiver. For possible values, see NSDateFormatterStyle.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

defaultDate

Returns the default date for the receiver.

- (NSDate *)defaultDate

Return Value

The default date for the receiver.

Discussion

The default default date is nil.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

eraSymbols

Returns the era symbols for the receiver.

- (NSArray *)eraSymbols

Return Value

An array containing NSString objects representing the era symbols for the receiver (for example, {“B.C.E.”, “C.E.”}).

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

formatterBehavior

Returns the formatter behavior for the receiver.

- (NSDateFormatterBehavior)formatterBehavior

Return Value

The formatter behavior for the receiver. For possible values, see NSDateFormatterBehavior.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

generatesCalendarDates

Returns a Boolean value that indicates whether the receiver generates calendar dates.

- (BOOL)generatesCalendarDates

Return Value

YES if the receiver generates calendar dates, otherwise NO.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

getObjectValue:forString:range:error:

Returns by reference a date representation of a given string and the range of the string used, and returns a Boolean value that indicates whether the string could be parsed.

- (BOOL)getObjectValue:(out id *)obj forString:(NSString *)string range:(inout NSRange *)rangep error:(out NSError **)error

Parameters
obj

If the receiver is able to parse string, upon return contains a date representation of string.

string

The string to parse.

rangep

If the receiver is able to parse string, upon return contains the range of string used to create the date.

error

If the receiver is unable to create a date by parsing string, upon return contains an NSError object that describes the problem.

Return Value

YES if the receiver can create a date by parsing string, otherwise NO.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

gregorianStartDate

Returns the start date of the Gregorian calendar for the receiver.

- (NSDate *)gregorianStartDate

Return Value

The start date of the Gregorian calendar for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

init

Initializes and returns an NSDateFormatter instance.

- (id)init

Return Value

An NSDateFormatter instance initialized with locale, time zone, calendar, and behavior set to the appropriate default values.

Discussion

There are many new attributes you can get and set on a 10.4-style date formatter, including the locale, time zone, calendar, format string, the two-digit-year cross-over date, the default date which provides unspecified components, and there is also access to the various textual strings, like the month names. You are encouraged, however, not to change individual settings. Instead you should accept the default settings established on initialization and specify the format using setDateStyle:, setTimeStyle:, and appropriate style constants (see NSDateFormatterStyle—these are styles that the user can configure in the International preferences panel in System Preferences).

Special Considerations

If you want the Mac OS X 10.4 behavior but have not set the class’s default behavior to NSDateFormatterBehavior10_4, you also need to send the new instance a setFormatterBehavior: message with the argument NSDateFormatterBehavior10_4.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

isLenient

Returns a Boolean value that indicates whether the receiver uses heuristics when parsing a string.

- (BOOL)isLenient

Return Value

YES if the receiver has been set to use heuristics when parsing a string to guess at the date which is intended, otherwise NO.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

locale

Returns the locale for the receiver.

- (NSLocale *)locale

Return Value

The locale for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

longEraSymbols

Returns the long era symbols for the receiver

- (NSArray *)longEraSymbols

Return Value

An array containing NSString objects representing the era symbols for the receiver (for example, {“Before Common Era”, “Common Era”}).

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

monthSymbols

Returns the month symbols for the receiver.

- (NSArray *)monthSymbols

Return Value

An array of NSString objects that specify the month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

PMSymbol

Returns the PM symbol for the receiver.

- (NSString *)PMSymbol

Return Value

The PM symbol for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

quarterSymbols

Returns the quarter symbols for the receiver.

- (NSArray *)quarterSymbols

Return Value

An array containing NSString objects representing the quarter symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setAMSymbol:

Sets the AM symbol for the receiver.

- (void)setAMSymbol:(NSString *)string

Parameters
string

The AM symbol for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setCalendar:

Sets the calendar for the receiver.

- (void)setCalendar:(NSCalendar *)calendar

Parameters
calendar

The calendar for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setDateFormat:

Sets the date format for the receiver.

- (void)setDateFormat:(NSString *)string

Parameters
string

The date format for the receiver. See Data Formatting Programming Guide for Cocoa for a list of the conversion specifiers permitted in date format strings.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

setDateStyle:

Sets the date style of the receiver.

- (void)setDateStyle:(NSDateFormatterStyle)style

Parameters
style

The date style of the receiver. For possible values, see NSDateFormatterStyle.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

setDefaultDate:

Sets the default date for the receiver.

- (void)setDefaultDate:(NSDate *)date

Parameters
date

The default date for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setEraSymbols:

Sets the era symbols for the receiver.

- (void)setEraSymbols:(NSArray *)array

Parameters
array

An array containing NSString objects representing the era symbols for the receiver (for example, {“B.C.E.”, “C.E.”}).

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setFormatterBehavior:

Sets the formatter behavior for the receiver.

- (void)setFormatterBehavior:(NSDateFormatterBehavior)behavior

Parameters
behavior

The formatter behavior for the receiver. For possible values, see NSDateFormatterBehavior.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setGeneratesCalendarDates:

Sets whether the receiver generates calendar dates.

- (void)setGeneratesCalendarDates:(BOOL)b

Parameters
b

A Boolean value that specifies whether the receiver generates calendar dates.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setGregorianStartDate:

Sets the start date of the Gregorian calendar for the receiver.

- (void)setGregorianStartDate:(NSDate *)array

Parameters
array

The start date of the Gregorian calendar for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setLenient:

Sets whether the receiver uses heuristics when parsing a string.

- (void)setLenient:(BOOL)b

Parameters
b

YES to use heuristics when parsing a string to guess at the date which is intended, otherwise NO.

Discussion

If a formatter is set to be lenient, when parsing a string it uses heuristics to guess at the date which is intended. As with any guessing, it may get the result date wrong (that is, a date other than that which was intended).

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setLocale:

Sets the locale for the receiver.

- (void)setLocale:(NSLocale *)locale

Parameters
locale

The locale for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

setLongEraSymbols:

Sets the long era symbols for the receiver.

- (void)setLongEraSymbols:(NSArray *)array

Parameters
array

An array containing NSString objects representing the era symbols for the receiver (for example, {“Before Common Era”, “Common Era”}).

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setMonthSymbols:

Sets the month symbols for the receiver.

- (void)setMonthSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setPMSymbol:

Sets the PM symbol for the receiver.

- (void)setPMSymbol:(NSString *)string

Parameters
string

The PM symbol for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setQuarterSymbols:

Sets the quarter symbols for the receiver.

- (void)setQuarterSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the quarter symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setShortMonthSymbols:

Sets the short month symbols for the receiver.

- (void)setShortMonthSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the short month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setShortQuarterSymbols:

Sets the short quarter symbols for the receiver.

- (void)setShortQuarterSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the short quarter symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setShortStandaloneMonthSymbols:

Sets the short standalone month symbols for the receiver.

- (void)setShortStandaloneMonthSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the short standalone month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setShortStandaloneQuarterSymbols:

Sets the short standalone quarter symbols for the receiver.

- (void)setShortStandaloneQuarterSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the short standalone quarter symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setShortStandaloneWeekdaySymbols:

Sets the short standalone weekday symbols for the receiver.

- (void)setShortStandaloneWeekdaySymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the short standalone weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setShortWeekdaySymbols:

Sets the short weekday symbols for the receiver.

- (void)setShortWeekdaySymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the short weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setStandaloneMonthSymbols:

Sets the standalone month symbols for the receiver.

- (void)setStandaloneMonthSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the standalone month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setStandaloneQuarterSymbols:

Sets the standalone quarter symbols for the receiver.

- (void)setStandaloneQuarterSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the standalone quarter symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setStandaloneWeekdaySymbols:

Sets the standalone weekday symbols for the receiver.

- (void)setStandaloneWeekdaySymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the standalone weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setTimeStyle:

Sets the time style of the receiver.

- (void)setTimeStyle:(NSDateFormatterStyle)style

Parameters
style

The time style for the receiver. For possible values, see NSDateFormatterStyle.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

setTimeZone:

Sets the time zone for the receiver.

- (void)setTimeZone:(NSTimeZone *)tz

Parameters
tz

The time zone for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

setTwoDigitStartDate:

Sets the two-digit start date for the receiver.

- (void)setTwoDigitStartDate:(NSDate *)date

Parameters
date

The earliest date that can be denoted by a two-digit year specifier.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setVeryShortMonthSymbols:

Sets the very short month symbols for the receiver.

- (void)setVeryShortMonthSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the very short month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setVeryShortStandaloneMonthSymbols:

Sets the very short standalone month symbols for the receiver.

- (void)setVeryShortStandaloneMonthSymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the very short standalone month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setVeryShortStandaloneWeekdaySymbols:

Sets the very short standalone weekday symbols for the receiver.

- (void)setVeryShortStandaloneWeekdaySymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the very short standalone weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setVeryShortWeekdaySymbols:

Sets the vert short weekday symbols for the receiver

- (void)setVeryShortWeekdaySymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the very short weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

setWeekdaySymbols:

Sets the weekday symbols for the receiver.

- (void)setWeekdaySymbols:(NSArray *)array

Parameters
array

An array of NSString objects that specify the weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

shortMonthSymbols

Returns the array of short month symbols for the receiver.

- (NSArray *)shortMonthSymbols

Return Value

An array containing NSString objects representing the short month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

shortQuarterSymbols

Returns the short quarter symbols for the receiver.

- (NSArray *)shortQuarterSymbols

Return Value

An array containing NSString objects representing the short quarter symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

shortStandaloneMonthSymbols

Returns the short standalone month symbols for the receiver.

- (NSArray *)shortStandaloneMonthSymbols

Return Value

An array of NSString objects that specify the short standalone month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

shortStandaloneQuarterSymbols

Returns the short standalone quarter symbols for the receiver.

- (NSArray *)shortStandaloneQuarterSymbols

Return Value

An array containing NSString objects representing the short standalone quarter symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

shortStandaloneWeekdaySymbols

Returns the array of short standalone weekday symbols for the receiver.

- (NSArray *)shortStandaloneWeekdaySymbols

Return Value

An array of NSString objects that specify the short standalone weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

shortWeekdaySymbols

Returns the array of short weekday symbols for the receiver.

- (NSArray *)shortWeekdaySymbols

Return Value

An array of NSString objects that specify the short weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

standaloneMonthSymbols

Returns the standalone month symbols for the receiver.

- (NSArray *)standaloneMonthSymbols

Return Value

An array of NSString objects that specify the standalone month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

standaloneQuarterSymbols

Returns the standalone quarter symbols for the receiver.

- (NSArray *)standaloneQuarterSymbols

Return Value

An array containing NSString objects representing the standalone quarter symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

standaloneWeekdaySymbols

Returns the array of standalone weekday symbols for the receiver.

- (NSArray *)standaloneWeekdaySymbols

Return Value

An array of NSString objects that specify the standalone weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

stringFromDate:

Returns a string representation of a given date formatted using the receiver’s current settings.

- (NSString *)stringFromDate:(NSDate *)date

Parameters
date

The date to format.

Return Value

A string representation of date formatted using the receiver’s current settings.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

timeStyle

Returns the time style of the receiver.

- (NSDateFormatterStyle)timeStyle

Return Value

The time style of the receiver. For possible values, see NSDateFormatterStyle.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Related Sample Code
Declared In
NSDateFormatter.h

timeZone

Returns the time zone for the receiver.

- (NSTimeZone *)timeZone

Return Value

The time zone for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

twoDigitStartDate

Returns the earliest date that can be denoted by a two-digit year specifier.

- (NSDate *)twoDigitStartDate

Return Value

The earliest date that can be denoted by a two-digit year specifier.

Discussion

If the two-digit start date is set to January 6, 1976, then “January 1, 76” is interpreted as New Year's Day in 2076, whereas “February 14, 76” is interpreted as Valentine's Day in 1976.

The default date is December 31, 1949.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

veryShortMonthSymbols

Returns the very short month symbols for the receiver.

- (NSArray *)veryShortMonthSymbols

Return Value

An array of NSString objects that specify the very short month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

veryShortStandaloneMonthSymbols

Returns the very short month symbols for the receiver.

- (NSArray *)veryShortStandaloneMonthSymbols

Return Value

An array of NSString objects that specify the very short standalone month symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

veryShortStandaloneWeekdaySymbols

Returns the array of very short standalone weekday symbols for the receiver.

- (NSArray *)veryShortStandaloneWeekdaySymbols

Return Value

An array of NSString objects that specify the very short standalone weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

veryShortWeekdaySymbols

Returns the array of very short weekday symbols for the receiver.

- (NSArray *)veryShortWeekdaySymbols

Return Value

An array of NSString objects that specify the very short weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

weekdaySymbols

Returns the array of weekday symbols for the receiver.

- (NSArray *)weekdaySymbols

Return Value

An array of NSString objects that specify the weekday symbols for the receiver.

Availability
  • Available in iPhone OS 2.0 and later.
See Also
Declared In
NSDateFormatter.h

Constants

NSDateFormatterStyle

The following constants specify predefined format styles for dates and times.

typedef enum {
   NSDateFormatterNoStyle     = kCFDateFormatterNoStyle,
   NSDateFormatterShortStyle  = kCFDateFormatterShortStyle,
   NSDateFormatterMediumStyle = kCFDateFormatterMediumStyle,
   NSDateFormatterLongStyle   = kCFDateFormatterLongStyle,
   NSDateFormatterFullStyle   = kCFDateFormatterFullStyle
} NSDateFormatterStyle;
Constants
NSDateFormatterNoStyle

Specifies no style.

Equal to kCFDateFormatterNoStyle.

Available in iPhone OS 2.0 and later.

Declared in NSDateFormatter.h.

NSDateFormatterShortStyle

Specifies a short style, typically numeric only, such as “11/23/37” or “3:30pm”.

Equal to kCFDateFormatterShortStyle.

Available in iPhone OS 2.0 and later.

Declared in NSDateFormatter.h.

NSDateFormatterMediumStyle

Specifies a medium style, typically with abbreviated text, such as “Nov 23, 1937”.

Equal to kCFDateFormatterMediumStyle.

Available in iPhone OS 2.0 and later.

Declared in NSDateFormatter.h.

NSDateFormatterLongStyle

Specifies a long style, typically with full text, such as “November 23, 1937” or “3:30:32pm”.

Equal to kCFDateFormatterLongStyle.

Available in iPhone OS 2.0 and later.

Declared in NSDateFormatter.h.

NSDateFormatterFullStyle

Specifies a full style with complete details, such as “Tuesday, April 12, 1952 AD” or “3:30:42pm PST”.

Equal to kCFDateFormatterFullStyle.

Available in iPhone OS 2.0 and later.

Declared in NSDateFormatter.h.

Discussion

The format for these date and time styles is not exact because they depend on the locale, user preference settings, and the operating system version. Do not use these constants if you want an exact format.

Availability
  • Available in iPhone OS 2.0 and later.
Declared In
NSDateFormatter.h

NSDateFormatterBehavior

Constants that specify the behavior NSDateFormatter should exhibit.

typedef enum {
   NSDateFormatterBehaviorDefault = 0,
   NSDateFormatterBehavior10_0    = 1000,
   NSDateFormatterBehavior10_4    = 1040,
} NSDateFormatterBehavior;
Constants
NSDateFormatterBehaviorDefault

Specifies default formatting behavior.

Available in iPhone OS 2.0 and later.

Declared in NSDateFormatter.h.

NSDateFormatterBehavior10_0

Specifies formatting behavior equivalent to that in Mac OS X 10.0.

Available in iPhone OS 2.0 through iPhone OS 2.1.

Declared in NSDateFormatter.h.

NSDateFormatterBehavior10_4

Specifies formatting behavior equivalent for Mac OS X 10.4.

Available in iPhone OS 2.0 and later.

Declared in NSDateFormatter.h.

Availability
  • Available in iPhone OS 2.0 and later.
Declared In
NSDateFormatter.h


Last updated: 2009-04-26

Did this document help you? Yes It's good, but... Not helpful...