I'm trying to set a UIDatePicker to today's date, but the picker isn't behaving.
The code I'm using is pretty simple:
.h
IBOutlet UIDatePicker *datePicker;
.m
- (IBAction)setForCurrent:(id)sender
{
NSDate *today = [NSDate date];
[datePicker setDate:today animated:YES];
}
When I hit the button that is linked to the setForCurrent action, the picker does shift the Day, Month, Hours, and Minutes to the current time.
The issue is that the AM/PM roller always shifts to PM if the current time is in the AM. What is odd is that I've used NSLog to see what date the picker is seeing (datePicker.date
) , and it is the correct date.
When the button is hit a second time, the AM/PM roller shifts to be correct again.
Is there some way to work around this bug?