简体   繁体   English

NSDateFormatter与iOS6有关?

[英]NSDateFormatter Issue with iOS6?

I have a date string like 2012/10/11 21:46:31 +0000 我有一个日期字符串,如2012/10/11 21:46:31 +0000

And I have tried almost maximum number of combinations but everytime I am getting NSDate as null. 我尝试了几乎最大数量的组合,但是每次我将NSDate设置为null时。

NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
[fmt setDateFormat:@"yyyy/MM/dd HH:mm:ss"];
NSDate *fromDate = [fmt dateFromString:fromDateString];

I am using iOS6 我正在使用iOS6

where fromDateString= 2012/10/11 21:46:31 +0000 其中fromDateString= 2012/10/11 21:46:31 +0000

Try the following (include the timezone string): 请尝试以下操作(包括时区字符串):

NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
[fmt setDateFormat:@"yyyy/MM/dd HH:mm:ss Z"];
NSDate *fromDate = [fmt dateFromString:@"2012/10/11 21:46:31 +0000"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM