NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(timerFire:) userInfo:nil repeats:YES];
}
//////每隔一秒执行一次
- (void)timerFire:(NSTimer *)timer
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setYear:2016];
[components setMonth:12];
[components setDay:12];
[components setHour:12];
[components setMinute:0];
[components setSecond:0];
[components setNanosecond:0];
NSDate *fireDate = [calendar dateFromComponents:components];//目标时间
NSDate *today = [NSDate date];//当前时间
unsigned int unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond| NSCalendarUnitNanosecond;
NSDateComponents *d = [calendar components:unitFlags fromDate:today toDate:fireDate options:0];//计算时间差
NSLog(@"%@",[NSString stringWithFormat:@"%d天%d小时%d分%d秒%d毫秒", [d day], [d hour], [d minute], [d second],[d nanosecond]/10000000]);
// auctionTime.text = [NSString stringWithFormat:@"%d天%d小时%d%分%d秒", [d day], [d hour], [d minute], [d second]];//倒计时显示