This question already has an answer here:
- NSDateFormatter show wrong year 1 answer
I want to convert date from 23 May, 2017
to 23-05-2017
.
I have tried with the following code but it returns 25-12-2016
.
NSDateFormatter *oldFormatter = [NSDateFormatter new];
[oldFormatter setDateFormat:@"dd MMM, YYYY"];
NSDate *oldDate = [oldFormatter dateFromString:dateStr];
NSDateFormatter *newFormatter = [NSDateFormatter new];
[newFormatter setDateFormat:@"dd-MM-YYYY"];
I am using Xcode 8.2.1. Thank You.