开发者

help with NSDateFormater

I am trying to set the format for a given dateString but I am not able to get it working. Here is the code I am using:

[dateFormatter 开发者_运维问答setDateFormat:@"yyyy-MM-dd hh:mm:ss"];

date = [dateFormatter dateFromString:@"2011-05-08 18:31:42"];

but I keep getting (null) for the date, Any help would be appreciated.


hh should be HH. hh is for 12-hour time and HH is 24-hour time. Here's your code with the changes:

[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
date = [dateFormatter dateFromString:@"2011-05-08 18:31:42"];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜