美文网首页
获取当天时间区间

获取当天时间区间

作者: 骑着蜗牛做开发 | 来源:发表于2017-05-08 09:41 被阅读0次

    - (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;

    }

    相关文章

      网友评论

          本文标题:获取当天时间区间

          本文链接:https://www.haomeiwen.com/subject/jihmtxtx.html