0
NSDateFormatter *dtFormatter = [[NSDateFormatter alloc] init];
[dtFormatter setDateFormat:@"yyyy-MM-dd hh:mm a"];
NSDate *selectedDate = [[NSDate alloc] init];
selectedDate = [dtFormatter dateFromString:[NSString stringWithFormat:@"%@", [appDelegate.aryTime objectAtIndex:i]]];
NSLog(@"selected Date: %@", selectedDate);
NSLog(@"Today Date: %@", todayDate);
int interval = [todayDate compare:selectedDate];
我有这段代码。现在,发生的事情是,当我运行应用程序保持英国(他们使用AM和PM)的区域格式(从设置>常规>国际>设置区域格式)时,应用程序将两个日期进行比较。但是,如果我将区域格式更改为瑞典(而不是使用em和fm),则不会比较日期。是否有任何方法可以删除区域格式和比较日期的相关性?我试图在24小时格式转换它们,但没有帮助。NSDate区域格式问题
我认为瑞典使用24小时,而不是“em/fm”。 – Emil 2012-01-06 22:37:49