时间戳获取


    NSTimeZone *zone = [NSTimeZone systemTimeZone];

    NSInteger interval = [zone secondsFromGMTForDate: date];

    NSDate *localeDate = [date  dateByAddingTimeInterval: interval];

    NSDateComponents *comps = [[NSDateComponents alloc] init];

    [comps setHour:hour];

    NSCalendar *calender = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

    NSDate *mDate = [calender dateByAddingComponents:comps toDate:localeDate options:0];

    [comps release];

    [calender release];

    return mDate;


你可能感兴趣的:(时间戳获取)