NSDate 格式化程序 [英] NSDate formatter
本文介绍了NSDate 格式化程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
不幸的是,我尝试将字符串转换为 NSDATE,但没有成功.
I try to convert a string to NSDATE with no luck unfortunately.
美国东部时间 2010 年 10 月 22 日星期五 11:26:45
Friday, October 22, 11:26:45 ET 2010
我知道格式化选项 (http://sree.cc/objective-c/nsdate-format-string-in-objective-c) 但我无法让它工作.
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:@"???????"];
有人吗?
推荐答案
所以你可能需要这样的东西:
So you'd probably need something like:
[dateFormatter setDateFormat:@"eeee, MMMM dd, HH:mm:ss z yyyy"];
eeee
- 当地星期几的拼写MMMM
- 月份拼写dd
- 一个月中没有前导零的日期HH
- 一天中的小时(24 小时制)mm
- 小时的分钟数(带前导零)ss
- 分钟的秒数(前导零)z
- 时区(短时间)yyyy
- 日历年eeee
- Local day of week spelled outMMMM
- Month spelled outdd
- day of month with no leading zerosHH
- 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
这篇关于NSDate 格式化程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文