一天之后添加'nd','st','rd'

时间:2012-01-24 19:56:22

标签: iphone objective-c ios5

  

可能重复:
  Ordinal Month-day Suffix Option for NSDateFormatter setDateFormat

我正在尝试显示Tues, Jan 24th 2012的日期。任何人都知道如何让th ndstrd出现?

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

0 个答案:

没有答案