我的日期选择器返回错误的分钟和秒值,但小时工作正常。这是我的获取方法。
-(NSDate *)datePickerTime
{
NSCalendar *gregorianCalendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
[gregorianCalendar setTimeZone:[NSTimeZone localTimeZone]];
NSDateFormatter *format = [[NSDateFormatter alloc]init];
[format setDateFormat:@"HH:mm:ss"];
[format setTimeZone:[NSTimeZone localTimeZone]];
NSString *dateString =[format stringFromDate:[self.timePicker date]];
NSDate *adjustedDate = [format dateFromString:dateString];
NSDateComponents *comp = [[NSDateComponents alloc]init];
comp = [gregorianCalendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:adjustedDate];
reminderTime = [gregorianCalendar dateFromComponents:comp];
return reminderTime;
}