How can I get only the date from a DatePicker component on iPhone? (better with a specific format).
A:
datePicker.datePickerMode = UIDatePickerModeDate;
From the documentation:
The exact order of these items depends on the locale setting.
Ole Begemann
2010-07-28 10:33:09
A:
thanks for the tip, but my problem is different. I want to get the date with [NSDate date] method, but I need only the date and non the complete timestamp.
Andrea Mattiuz
2010-07-28 10:48:59
A:
In your question you mention you want it from DatePicker component!
Anyways.. see NSDateFormatter
lukya
2010-07-28 13:04:57
A:
I believe that your answer can be found in this previous question: http://stackoverflow.com/questions/936969/nsdate-and-nsdateformatter-short-format-date-and-time-in-iphone-sdk
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];
bjtitus
2010-07-28 13:19:10
thanks to all,these tips were very useful!!
Andrea Mattiuz
2010-07-28 14:08:13