问题描述:

can anyone help me format this date "Tue, 09 Sep 2014" I've got "FFF, dd MMM yyyy" i got this of a NSDate table on some random forum :/ any help is greatly appreciated

Code:

for (NSString *rawDate in postDateraw){

NSString *formattedRawDate = [rawDate substringToIndex:[rawDate length]-15];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

[dateFormatter setDateFormat:@"FFF, dd MMM yyyy"];

NSDate *date = [dateFormatter dateFromString: formattedRawDate];

dateFormatter = [[NSDateFormatter alloc] init];

[dateFormatter setDateFormat:@"dd/MM/yyyy"];

NSString *convertedString = [dateFormatter stringFromDate:date]; NSLog(@"Converted String : %@",convertedString);

}

网友答案:

The character for day-of-week is E, not F. Thus:

[dateFormatter setDateFormat:@"EEE, dd MMM yyyy"];
相关阅读:
Top