判断是否在某个时间戳之前

//判断是否是多少秒前

  • (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;
    }

你可能感兴趣的:(判断是否在某个时间戳之前)