开发者

Objective-C: Unicode Date Format

开发者 https://www.devze.com 2022-12-14 10:20 出处:网络
I am trying to work out how to have the UNICODE representation of Sun, 03 May 2009 19:58:58 -0700 as eee, dd MMM yyyy HH:开发者_Python百科mm:s ZZZZ or something. I can\'t seem to get this working pre

I am trying to work out how to have the UNICODE representation of Sun, 03 May 2009 19:58:58 -0700 as eee, dd MMM yyyy HH:开发者_Python百科mm:s ZZZZ or something. I can't seem to get this working precisely.


Use an NSDateFormatter. It lets you set a particular format string, using the format specifiers from the Unicode spec, then get the formatted date from a given NSDate object using stringFromDate:. Also consider reading Apple's doc about formatting dates. Example:

// Given some NSDate *date
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"eee, dd MMM yyyy HH:mm:ss ZZZZ"];
NSString *formattedDate = [formatter stringFromDate:date];
0

精彩评论

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