I am getting nil returned for the date variable in the below code. I can't find开发者_StackOverflow社区 any problem with the date format, can anyone help?
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"EEE MMM dd HH:mm:ss zzz yyyy"];
NSString *dateString = [[NSString alloc] initWithFormat:@"%@", @"Mon Apr 05 04:37:28 UTC 2010"];
NSDate *date = [formatter dateFromString:dateString];
Try
NSDate *date = [formatter dateFromString:@"Mon Apr 05 04:37:28 GMT 2010"];
or
NSDate *date = [formatter dateFromString:@"Mon Apr 05 04:37:28 +0000 2010"];
精彩评论