我有一个NSDateformatter工作不正常。我以这样的字符串得到了我的日期。NSDateformatter格式不正确
2013-02-20 00:00:00
,我需要它返回作为一个NSDate这样
2013-02-20
什么我目前得到的是这个。
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
[dateFormat dateFromString:dateString]
但这不起作用。 有什么帮助吗?
你设置第二格式从字符串中提取的日期之前,你不存储提取日期的任何地方,然后你永远不转换追溯到一个字符串。 (请注意,NSDate中不包含任何格式信息。) –
(基本上,你没有想到你正在做什么,但你有责任在NSDateFormatter上指责它。) –
“foggiest idea ... “ - 现在多数民众赞成是我会肯定同化的一个词组! – vikingosegundo