获取当天时间区间

- (NSDictionary *)getCuttentDayPeriod {

NSDate *date = [NSDate date];

NSCalendar *calendar = [NSCalendar currentCalendar];

NSDateComponents *comps = [calendar components: NSCalendarUnitEra |NSCalendarUnitYear | NSCalendarUnitMonth| NSCalendarUnitDay| NSCalendarUnitHour  fromDate: date];

[comps setHour:8];

[comps setHour:8];

NSDate *beginDate = [calendar dateFromComponents:comps];

NSDate *endDate = [beginDate dateByAddingTimeInterval:3600*24];

NSString *beginStr = [NSString stringWithFormat:@"%.f",[beginDate timeIntervalSince1970]];

NSString *endStr = [NSString stringWithFormat:@"%.f",[endDate timeIntervalSince1970]];

NSDictionary *dct = [[NSDictionary alloc] initWithObjects:@[beginStr, endStr] forKeys:@[@"beginDate", @"endDate"]];

return dct;

}

你可能感兴趣的:(获取当天时间区间)