开发者

return nil for dateFromString call of NSDateFormatter

I am getting nil returned for the date variable in the below code. I can't find开发者_StackOverflow社区 any problem with the date format, can anyone help?

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"EEE MMM dd HH:mm:ss zzz yyyy"];

NSString *dateString = [[NSString alloc] initWithFormat:@"%@", @"Mon Apr 05 04:37:28 UTC 2010"];
NSDate *date = [formatter dateFromString:dateString];


Try

NSDate *date = [formatter dateFromString:@"Mon Apr 05 04:37:28 GMT 2010"];

or

NSDate *date = [formatter dateFromString:@"Mon Apr 05 04:37:28 +0000 2010"];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜