I am converting this date string "05/20/2015 05:27 pm"
into NSDate
with the help of formatter but it returns nil
.
-(NSDate *)dateFromString:(NSString *)strDate withFormat:(NSString *)strDateFormat
{
NSDate *date = nil;
[self.dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
if (strDate) {
if (strDateFormat) {
[self.dateFormatter setDateFormat:strDateFormat];
}
date = [self.dateFormatter dateFromString:strDate];
}
return date;
}
I am using the above function where I am passing the string as "05/20/2015 05:27 pm"
with format @"dd/MM/yyyy HH:mm:ss"
.