我想比較兩個日期。我以yyyy-dd-mm格式獲取設備日期,並從webservices獲取mm-dd-yyyy。我想更改設備日期格式並在NSDate
對象中獲取該更改日期。這裏是我的代碼:自定義格式的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);
這個[dateFormatter集合]是做什麼的? – Krishnabhadra 2011-05-23 12:23:36
我編輯了代碼... :) – Swapnil 2011-05-23 12:27:30