Good day. Tell me how to set the starting date. Initially, it is "today" And I need as much as 1990! = (

Thanks in advance.

  • one
    Need to get NSDate? or the start date in the UIDatePicker component? - Alexander Sviridov

2 answers 2

NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd"]; [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; NSDate *someDate = [dateFormatter dateFromString:@"1990-01-01"]; NSLog(@"%@", someDate); [dateFormatter release]; 

    See the UIDatePicker class UIDatePicker .

    There is a date property:

     date The date displayed by the date picker. @property(nonatomic, retain) NSDate *date Discussion The default is the date when the UIDatePicker object is created. The date is ignored in the mode UIDatePickerModeCountDownTimer; for that mode, the date picker starts at 0:00. Setting this property does not animate the date picker by spinning the wheels to the new date and time; to do that you must use the setDate:animated: method. 

    This is how to work with NSDate