我想在设置时间时获得本地通知,所以在时间选择器中,我得到了时间格式,例如上午 07:14 上午/下午,我需要转换为 19:14,以便我可以设置如下值
我想将 07 转换为 19 如何将值放入 datecomponet..
//getting time format 07:14 Am/Pm
NSString * time1 = Timepicker.text;
NSArray *array = [time1 componentsSeparatedByString:@":"];
[datecomponet setHour:19];
[datecomponet setMinute:38];
[dateformater setDateFormat:@"hh:mm a"];
self.Timepicker.text= [NSString stringWithFormat:@"%@",[dateformater stringFromDate:datepicker.date]];
/// This is local notification code
NSCalendar * gregcalender = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
[gregcalender setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"IST"]];
NSDateComponents *datecomponet = [gregcalender components:NSCalendarUnitYear|NSCalendarUnitMonth | NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:date];
// [datecomponet setYear:2017];
// [datecomponet setMonth:12];
// [datecomponet setDay:16];
// [datecomponet setHour:18];
// [datecomponet setMinute:38];
NSInteger year = [datecomponet year];
NSInteger month = [datecomponet month];
NSInteger day = [datecomponet day];
NSString * time1 = Timepicker.text;
// NSInteger hour = [datecomponet hour];
// NSInteger min = [datecomponet minute];
//NSString *testString= @"It's a rainy day";
NSArray *array = [time1 componentsSeparatedByString:@":"];
[datecomponet setHour:18];
[datecomponet setMinute:38];
UIDatePicker * dd = [[UIDatePicker alloc]init];
[dd setDate:[gregcalender dateFromComponents:datecomponet]];
NSLog(@"======>NSNotification method tab<=====");