可能重复:
Ordinal Month-day Suffix Option for NSDateFormatter setDateFormat
我正在尝试显示Tues, Jan 24th 2012
的日期。任何人都知道如何让th
nd
,st
,rd
出现?
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"];
[dateFormatter setDateFormat:@"E, MMM dd, YYYY"];
longDate = [dateFormatter stringFromDate:currDate];
NSLog(@"%@",longDate);
将显示Tue, Jan 24, 2012