开发者

How to format date to Fri-05 Aug

开发者 https://www.devze.com 2023-02-02 20:35 出处:网络
I have followed the Apple documentation and I am having no success: - (NS开发者_StackOverflow中文版String *)formatDepartureDateForColumn:(NSDate *)departureDate

I have followed the Apple documentation and I am having no success:

- (NS开发者_StackOverflow中文版String *)formatDepartureDateForColumn:(NSDate *)departureDate
{
    NSString *result;
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

    [dateFormatter setDateFormat: @"%a-%d %b"]; 
    result = [dateFormatter stringFromDate: departureDate];

    [dateFormatter release];
    return result;

}

Anyone have any ideas? I want the date formatted like this Fri-05 Aug


The documentation you refer to is for OS X 10.3 and earlier. Try:

[dateFormatter setDateFormat:@"E-dd MMM"]

See Date Formatters for OS X and iOS. Since 10.4 unicode formats have been used.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号