I have a string in the form of
"11:00AM, Saturday August 21, 2010"
How do I convert this to an NSDate object?
I have a string in the form of
"11:00AM, Saturday August 21, 2010"
How do I convert this to an NSDate object?
Use a NSDateFormatter for this format. -(NSDate *)dateFromString:(NSString *)string
is the method you want to use then.
This should work:
NSString *input = @"11:00AM, Saturday August 21, 2010";
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:@"hh:mma, EEEE MMMM d, yyyy"];
NSDateFormatter *df2 = [[[NSDateFormatter alloc] init] autorelease];
[df2 setDateFormat:@"MMMM yyyy"];
NSDate *date = [df2 stringFromDate:[df dateFromString:input]];
And format your date object as you want.
http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns