NSDate formatter

随声附和 提交于 2019-12-22 11:14:11

问题


I try to convert a string to NSDATE with no luck unfortunately.

Friday, October 22, 11:26:45 ET 2010

I know the options for formatting (http://sree.cc/objective-c/nsdate-format-string-in-objective-c) but i cant get it to work.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"???????"];

anyone?


回答1:


Date Format Specifiers.

So you'd probably need something like:

[dateFormatter setDateFormat:@"eeee, MMMM dd, HH:mm:ss z yyyy"];
  • eeee - Local day of week spelled out
  • MMMM - Month spelled out
  • dd - day of month with no leading zeros
  • HH - hour of day (24 hour format)
  • mm - minutes of hour (with leading zero)
  • ss - seconds of minute (with leading zero)
  • z - timezone (short wall time)
  • yyyy - calendar year


来源:https://stackoverflow.com/questions/4685146/nsdate-formatter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!