UIDatePicker (4.2.1) shows differing dates for the modes UIDatePickerDate (correct), and
UIDatePickerDateAndTime (incorrect) when the timezone you assign to the UIDatePicker is - more than 12 hours ahead (east) of the systemTimeZone of the iPhone. For example, device system time zone = America/Los Angeles = GMT - 8 Honolulu date: Dec 7, 1941 7:48am Tokyo date: Dec 8, 1941 3:18am UIDatePicker will show the Tokyo date for mode UIDatePickerDate (correct): Dec 8, 1941 UIDatePickerDateAndTime: Dec 7, 1941 In fact, UIDatePicker will show incorrect dates in this case for any time zone east of GMT + 4 (always one day before correct day) A work-around in viewDidLoad is: self.datePicker.datePickerMode = UIDatePickerModeDateAndTime; self.datePicker.minuteInterval = 1; self.datePicker.timeZone = timeZone; [NSTimeZone setDefaultTimeZone:timeZone]; // *** add this line to force date picker to show correct date in all modes [self.datePicker setDate:tzDate animated:YES]; and in viewWillDisappear add: [NSTimeZone resetSystemTimeZone]; [NSTimeZone setDefaultTimeZone:[NSTimeZone systemTimeZone]]; Not super happy about the work-around, but it should be fairly robust even if this bug is fixed in future. If anyone can shed some light on this behavior, please advise. No amount of fooling around with calendars, locales, etc. fixed this until i reset the default zone. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com