我想比较两个日期。我正在以yyyy-dd-mm格式获取设备日期,并从webservices获得mm-dd-yyyy。我想更改设备日期格式并在NSDate
对象中获取更改日期。这是我的代码:
NSDate *today = [[NSDate alloc] init];
NSLog(@"today : %@", today);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM dd yy"];
NSString *tString = [dateFormatter stringFromDate:today];
NSLog(@"tString : %@",tString);
NSDate *date = [dateFormatter dateFromString:tString];
NSLog(@"date : %@",date);
答案 0 :(得分:0)