iOS 时间,时间戳 ,nsstring ,NSTimeInterval,日期间的比较
时间比较
- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate;
@property (readonly) NSTimeInterval timeIntervalSinceNow;
@property (readonly) NSTimeInterval timeIntervalSince1970;
得到早期时间
- (NSDate *)earlierDate:(NSDate *)anotherDate;
得到晚的时间
- (NSDate *)laterDate:(NSDate *)anotherDate;
比较两个时间是否相等
- (BOOL)isEqualToDate:(NSDate *)otherDate;
-(BOOL)isMyTimeTimer:(NSNumber *)dateNum
{
// 两个给的时间是否大于现在时间
NSDateFormatter *famtter = [[NSDateFormatter alloc] init];
famtter.dateFormat = @"yyyyMMdd";
// 这个时间是要注意的 我这里时有HH:ss:mm的时间戳 ---- jwcai
NSString *time1=[famtter stringFromDate:[NSDate dateWithTimeIntervalSince1970:dateNum.doubleValue/1000]];
NSDate *date_new = [NSDate date];
NSString *time2=[famtter stringFromDate:date_new];
return [time2 doubleValue] - [time1 doubleValue] >= 0;
}- 上一篇:没有了
- 下一篇:没有了