如何計算NSTimeInterval當日時間的時,分,秒為零點?
我只得到NSTimeInterval :
NSTimeInterval today = [[NSDate date] timeIntervalSince1970];
如何重置為00:00:00?
NSDate *currentDate = [NSDate date];
NSDateComponents *currentDateComponents = [calendar components:NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:currentDate];
NSDateComponents *currentDateToMidnight = [[NSDateComponents alloc] init];
[currentDateToMidnight setHour:-[currentDateComponents hour]];
[currentDateToMidnight setMinute:-[currentDateComponents minute]];
[currentDateToMidnight setSecond:-[currentDateComponents second]];
NSDate *midnight = [calendar dateByAddingComponents:currentDateToMidnight toDate:currentDate options:0];
NSTimeInterval todayTimeInterval = [midnight timeIntervalSince1970];