我想将字符串Thu, Nov 22, 2012转换为NSDate
.
我试过这个:
NSString *str = @"Thu, Nov 22, 2012";
[dateFormat setDateFormat:@"EEE,MMM dd yyyy"];
NSDate *date = [dateFormat dateFromString:str];
NSLog(@"date: %@",date);
但我越来越空了。我究竟做错了什么 ?
我想将字符串Thu, Nov 22, 2012转换为NSDate
.
我试过这个:
NSString *str = @"Thu, Nov 22, 2012";
[dateFormat setDateFormat:@"EEE,MMM dd yyyy"];
NSDate *date = [dateFormat dateFromString:str];
NSLog(@"date: %@",date);
但我越来越空了。我究竟做错了什么 ?
NSString
date
format
并且NSDateFormatter
应该是same
:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
NSString *string = @"Thu, Nov 22, 2012";
[dateFormat setDateFormat:@"EEE,MMM dd, yyyy"]; //your date formatter is not correct
NSDate *date = [dateFormat dateFromString:string];
NSLog(@"%@",date);