Type Method

dateWithString:

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

Declaration

+ (id)dateWithString:(NSString *)aString;

Parameters

aString

A string that specifies a date and time value in the international string representation format—YYYY-MM-DD HH:MM:SS ±HHMM, where ±HHMM is a time zone offset in hours and minutes from UTC (for example, “2001-03-24 10:45:32 +0600”).

You must specify all fields of the format string, including the time zone offset, which must have a plus or minus sign prefix.

Return Value

An NSDate object with a date and time value specified by aString.

Discussion

To create a date object from a string, you should typically use a date formatter object instead (see NSDateFormatter and Data Formatting Guide).

See Also

Legacy Operations

+ dateWithNaturalLanguageString:

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

Deprecated
+ dateWithNaturalLanguageString:locale:

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

Deprecated
- initWithString:

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

Deprecated
- addTimeInterval:

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

Deprecated
- dateWithCalendarFormat:timeZone:

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

Deprecated
- descriptionWithCalendarFormat:timeZone:locale:

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

Deprecated