I have an date string which looks like this:
2011-10-01 08:45:34 +0000
How can I format it with NSDate? Thanks :D
I have an date string which looks like this:
2011-10-01 08:45:34 +0000
How can I format it with NSDate? Thanks :D
you can try this method in NSDateFormatter
- (NSDate *)dateFromString:(NSString *)string
an example
dateFormatter = [[NSDateFormatter alloc] init];
NSLocale *en_US = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[dateFormatter setLocale:en_US];
[en_US release];
[dateFormatter setDateFormat:@"MM/dd/yyyy h:mm:ss a"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:-60*60*7]];
NSDate *date = [dateFormatter dateFromString:dateString];
[dateFormatter release];