I'm having a few strange issues with the UIDatePicker. I checked the forums and I haven't had any luck with the answers supplied.
Say I pick a date, 20/11/2010 EN_AUS locale. When I NSLog it the date property is 2010-11-19 13:00:00 +0000. But when I format it and display in a label it appears correct, i.e. 20/11/2010?!
I save this date so that the next time the user enters this view the uiDatePicker should automatically be set at the last selected date. But it just isn't happening, it still displays the current date.
I've listed the important code below, any advice is appreciated :)
// setting up the uiDatePicker
NSLocale *ozLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_AUS"];
self.datePicker.calendar = [NSCalendar autoupdatingCurrentCalendar];
[NSTimeZone setDefaultTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:39600]]; // Melbourne time zone
[self.datePicker setLocale:ozLocale];
self.datePicker.timeZone = [NSTimeZone localTimeZone];
[ozLocale release];
// displaying the date from the uidatePicker
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
self.dateLabel.text = [dateFormatter stringFromDate:self.datePicker.date];
[dateFormatter release];
// In viewWillAppear I set the uiDatePicker. lastDatePicked has the value of 2010-11-19 13:00:00 +0000 at this point
[self.datePicker setDate:self.appDelegate.lastDatePicked animated:FALSE];