我有一个2 NSDates
,一个startdate
和enddate
。这些日期有以下格式。比较NSDates在objective-c
startDate = 2013-02-22 12:00:00 +0000; endDate = 2013-02-25 13:00:00 +0000;
现在我想比较这些日期。所以我有这个代码。
if([event.startDate isEqualToDate:event.endDate]){
NSLog(@"event %@ is in the same day",event.title);
}else{
NSLog(@"event %@ is NOT in the same day",event.title);
}
但问题是它总是在else语句中。我希望如果startDate和endDate在同一天,每月和每年他们给我第一个NSLog
否则他们给我第二个NSLog
任何帮助?
取下日期时间元素:http://stackoverflow.com/questions/3916392/removing-time-components-from-an-nsdate-object-using-objective-c-cocoa – trojanfoe 2013-02-13 08:23:11
你是使用NSDateFormatter将字符串转换为日期? – 2013-02-13 08:28:24