Shirish
Shirish

Reputation: 295

UIDateTime Picker without minutes and seconds in iOS

How to make UIDateTimePicker with only Date and hour and am/pm.(NO MINUTES OR SECONDS TO DISPLAY !)

Upvotes: 1

Views: 988

Answers (2)

Ahmed Abdallah
Ahmed Abdallah

Reputation: 2355

_datepicker.datePickerMode= UIDatePickerModeDate;
[_datepicker reloadInputViews];

Upvotes: 0

Bharath Vankireddy
Bharath Vankireddy

Reputation: 932

Change the mode of the DatePicker from the storyboard. Find attached screenshot. Change date picker mode

    NSDate * date = picker.date;
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
   [df setDateFormat:@"d:hh a"];
   NSLog(@"picker time: %@", [df stringFromDate:[NSDate date]]);

Here picker is the IBoutlet reference for UIDatePicker.

Upvotes: 2

Related Questions