Objective c NSDateformatter不兼容格式
几乎什么都试过了,结果无效, 我作为参数'NSString'传递的格式:Objective c NSDateformatter不兼容格式,objective-c,cocoa-touch,nsdate,nsdateformatter,Objective C,Cocoa Touch,Nsdate,Nsdateformatter,几乎什么都试过了,结果无效, 我作为参数'NSString'传递的格式:2013年11月13日星期三 -(NSDate*)stringToDate:(NSString*)dateString{ NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; // [dateFormat setDateFormat:@"EE, d-LLLL-yyyy HH:mm:ss Z"]; // [dateFormat setD
2013年11月13日星期三
-(NSDate*)stringToDate:(NSString*)dateString{
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
// [dateFormat setDateFormat:@"EE, d-LLLL-yyyy HH:mm:ss Z"];
// [dateFormat setDateFormat:@"EE, dd-MM-yyyy"];
[dateFormat setDateFormat:@"EEE, dd-MM-yyyy"];
// NSString *str = [dateString stringByAppendingString:@" 09:00:00 +0000"];
// NSDate *date = [dateFormat dateFromString:dateString];
NSDate *date = [dateFormat dateFromString:dateString];
return date;
}
嗨,试试看,它对我有用:
-(NSDate*)stringToDate:(NSString*)dateString{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"EEE dd-MM-yyyy ";
[dateFormatter setLocale:[NSLocale currentLocale]];
NSDate *date = [dateFormatter dateFromString:dateString];
return date
}
嗨,试试看,它对我有用:
-(NSDate*)stringToDate:(NSString*)dateString{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"EEE dd-MM-yyyy ";
[dateFormatter setLocale:[NSLocale currentLocale]];
NSDate *date = [dateFormatter dateFromString:dateString];
return date
}
删除逗号。它应该删除逗号。它应该工作有趣,这也给了我(空)。你在iOS 7下运行它吗?Upps。不,OSX10.9(错过了)很有趣,这也给了我(空)。你在iOS7下运行它吗?Upps。没有,OSX10.9(错过了)