I'm stuck. Can someone please lend a hand with what the format specifier for setDateFormat needs to me to read in a date in the following format:
Monday, October 31 2011 7:00pm"
Disclosure: Been doing iOS for about a month. C, C++, python for lots of years.
Code:
// dateStr: "Monday, October 31 2011 7:00pm"
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"EEEE, MMMM d yyyy"];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
NSDate *date1 = [dateFormatter dateFromString:dateStr];
// date1 == nil
[dateFormatter setDateFormat:@"EEEE, MMMM d yyyy hh:mma"]; // works, sort of
NSDate *date2 = [dateFormatter dateFromString:dateStr];
// date2 == 2011-11-01 00:00:00 +0000
[dateFormatter setDateFormat:@"EEEE, MMMM d yyyy hh:mm a"]; // fails
NSDate *date3 = [dateFormatter dateFromString:dateStr];
// date3 == nil
[dateFormatter setDateFormat:@"EEEE, MMMM d yyyy hh:mm"]; // fails
NSDate *date4 = [dateFormatter dateFromString:dateStr];
// date4 == nil
Thank you.