判断是否在某个时间戳之前
2017-07-21 本文已影响8人
涛涛灬灬
//判断是否是多少秒前
-
(BOOL)isBefore:(NSString *)dateString gap:(NSTimeInterval)timeInterval
{
NSDate *date = [NSDate dateWithTimeIntervalSince1970:[dateString doubleValue]/1000];
return [self isBeforeWithDate:date gap:timeInterval];
} -
(BOOL)isBeforeWithDate:(NSDate *)date gap:(NSTimeInterval)timeInterval
{
NSDate *tenMinut = [NSDate dateWithTimeIntervalSinceNow:timeInterval];NSComparisonResult result = [date compare:tenMinut];
if (result == NSOrderedDescending) {
return NO;
}
return YES;
}