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"];
精彩评论