开发者

DatePicker iPhone get only date

开发者 https://www.devze.com 2023-01-09 09:21 出处:网络
How can I get only the开发者_Go百科 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 int

How can I get only the开发者_Go百科 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.


In your question you mention you want it from DatePicker component!

Anyways.. see NSDateFormatter

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号