문제

I am using UIDatePicker to select the date. I have selected only DateMode in this. Sometimes, its behaving differently

If i select December 17,2014 in calander. Its giving me the string as selected date is 2014-12-351 and it should be 2014-12-17 instead.

code below is used to get the string from UIDatePicker.

  NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"YYYY-MM-DD"];
  NSString *selectedDate = [NSString stringWithFormat:@"%@",
                              [df stringFromDate:datepicker.date]];

Please help me in this

도움이 되었습니까?

해결책

From @Hot Licks comment,

Use correct date format as yyyy-MM-dd. For further reference read Date Format Patterns

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top