I'm converting a date to text to display in a text box and it converts fine. The 29,30 and 31 December 2013 gets converted to 2014 and 29,30 and 31 December 2014 gets converted to 2015.
This is my code to convert the date to text
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd MMM YYYY"];
self.pickupDateTextField.text = [dateFormatter stringFromDate:[self.datePicker date]];
NSLog(@"%@ %@",self.datePicker.date,self.pickupDateTextField.text);
This is what the NSLog
is printing.
2013-12-29 06:58:14 +0000 29 Dec 2014
The correct date formatter string is as below:
It should have small "yyyy" and not the capital "YYYY".