I want to get day/month and hour:minute from "12/10/2015 6:11:04 PM" format date. I am from Turkey so our date format is 23 hours. When I use the code below, it returns date "nil".
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"tr_TR_POSIX"]];
[dateFormatter setDateFormat:@"d/m/yyyy h:mm:ss a"];
NSDate *date = [dateFormatter dateFromString:@"12/10/2015 6:11:04 PM"];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:(NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:date];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
change dateformat like and try
[dateFormatter setDateFormat:@"dd/MM/yyyy h:mm:ss a"];