tags:

views:

519

answers:

1

I have a UIDatePicker on my view.

I have set DatePicker in time mode.

So user can select only time.

Whatever time is selected by user should be displayed in a textbox..

I dont know how to display time value - that is set by user through DatePicker - time mode.

please help me..

+1  A: 

You'll need to use NSDateFormatter to format the NSDate returned by your UIDatePicker. Here's some untested sample code, assuming you have a UILabel as property "myLabel" and a UIDatePicker as property "myDatePicker":

NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"h:mm a"];

self.myLabel.text = [outputFormatter stringFromDate:self.myDatePicker.date];

[outputFormatter release];

You'll want to check the date format patterns on the Unicode Locale Data Markup Language page. The string "h:mm a" will give you something like "12:08 PM" depending on your locale.

pix0r