开发者

help with NSDateFormater

开发者 https://www.devze.com 2023-03-06 03:49 出处:网络
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:

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

精彩评论

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