Objective-C:Unicode 日期格式

发布于 2024-08-15 05:10:58 字数 113 浏览 3 评论 0 原文

我正在尝试找出如何使用 UNICODE 表示 Sun, 03 May 2009 19:58:58 -0700 as eee, dd MMM yyyy HH:mm:s ZZZZ 或其他。我似乎无法让它精确地工作。

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:mm:s ZZZZ or something. I can't seem to get this working precisely.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咿呀咿呀哟 2024-08-22 05:10:58

使用 NSDateFormatter 。它允许您使用 Unicode 规范,然后使用 stringFromDate:。另请考虑阅读有关 格式化日期。例子:

// 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];

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文