这个主要是从网上看到的 感觉非常好打算保存起来
-(NSString *)compareDate:(NSDate *)date{
NSTimeInterval secondsPerDay = 24 * 60 * 60;
NSDate *today = [[NSDate alloc] init];
NSDate *tomorrow, *yesterday;
tomorrow = [today dateByAddingTimeInterval: secondsPerDay];
yesterday = [today dateByAddingTimeInterval: -secondsPerDay];
// 10 first characters of description is the calendar date:
NSString * todayString = [[today description] substringToIndex:10];
NSString * yesterdayString = [[yesterday description] substringToIndex:10];
NSString * tomorrowString = [[tomorrow description] substringToIndex:10];
NSString * dateString = [[date description] substringToIndex:10];
if ([dateString isEqualToString:todayString])
{
return @"今天";
} else if ([dateString isEqualToString:yesterdayString])
{
return @"昨天";
}else if ([dateString isEqualToString:tomorrowString])
{
return @"明天";
}
else
{
return dateString;
}
}