I have a function to convert NSString to NSDate.
+ (NSDate *)getNSDateFromString:(NSString *)strDate andFormat:(NSString *)format{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat : format];
NSString *stringTime = strDate;
NSDate *dateTime = [formatter dateFromString:stringTime];
return dateTime;
}
The value of strDate is "27-Mar-2018 18:28:09". The format is "dd-MM-yyyy HH:mm:ss"
That function is returning nil value. Can anyone help on this please. Thanks.