iOS -计算时间差

    NSDateFormatter *date = [[NSDateFormatter alloc]init];

    [date setDateFormat:@"yyyyMMddHH"];

    [date setTimeZone:[NSTimeZone systemTimeZone]];

    NSInteger timeSub = [[NSTimeZone systemTimeZone] secondsFromGMT];

    NSDate *endD = [endTime dateByAddingTimeInterval:timeSub];

    

    NSTimeInterval interval1 = [startD timeIntervalSince1970];

    NSTimeInterval interval2 = [endD timeIntervalSince1970];

    NSTimeInterval interval3 = interval2-interval1;

posted @ 2017-01-18 18:01  半窗疏影  阅读(209)  评论(0编辑  收藏  举报