NSDate datebysettinghour总是减去8

时间:2017-06-17 05:29:16

标签: ios objective-c nscalendar

以下是我的代码: -

-(NSDate *)getReminderDatetime
{
    NSArray *tempStrings = [self.selectedReminderInfo.reminderTime componentsSeparatedByString:@":"];
    NSInteger hour = [[tempStrings firstObject] integerValue];
    NSInteger min = [[tempStrings lastObject] integerValue];
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian];
    NSDate *reminderDate = [calendar dateBySettingHour:hour minute:min second:0 ofDate:self.selectedDate options:0];
    //reminderDate = [GeneralHelper convertToLocalTime:reminderDate];
    return reminderDate;
}

hour is 15min is 29的结果。所以右边的提醒日期应为2017-06-16 15:29:00 +0000。但是,它返回-8小时,即2017-06-16 09:29:00 +0000。如何将其修复为我想要的值?

0 个答案:

没有答案