Search code examples
iosuidatepicker

Date picker in iOS


I pick the date from date picker but it shows only time at the time of run.

I want only date, not time, but it show only time not date. I already set date format.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
DatePicker.datePickerMode = UIDatePickerModeTime;
NSString *formatedDate=[[NSString alloc]init];
formatedDate = [dateFormatter stringFromDate:self.DatePicker.date];
self.SelectedDate.text =formatedDate;

[DatePicker setMinimumDate: [NSDate date]];
_goDateForcustmoeDetail=formatedDate;
isTouchedFirst=NO;

Solution

  • Try changing

    DatePicker.datePickerMode = UIDatePickerModeTime;
    

    to

    DatePicker.datePickerMode = UIDatePickerModeDate;
    

    Only four modes are available:

    • UIDatePickerModeTime,
    • UIDatePickerModeDate,
    • UIDatePickerModeDateAndTime,
    • UIDatePickerModeCountDownTimer