How can I get only the date from a DatePicker component on iPhone? (better with a specific format).
I believe that your answer can be found in this previous question: Formatting NSDate into particular styles for both year, month, day, and hour, minute, seconds
Just take the date you get back from the datePicker and get just the day using NSDateFormatter:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSString *theDate = [dateFormat stringFromDate:pickerDate];
[dateFormat release];
datePicker.datePickerMode = UIDatePickerModeDate;
From the documentation:
The exact order of these items depends on the locale setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With