In my application i am using pickerview
My problem is that when in iOS 4.3 Picker view comes MM-dd-yy format,
For this you can make your custom picker.
Or you want to format the date then use this code..
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM-dd-yy"];
NSString *date = [dateFormat stringFromDate:datePicker.date];
NSLog(@"date is >>> , %@",date);
Check this
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 250, 325, 300)];
datePicker.datePickerMode = UIDatePickerModeDate;
datePicker.date = [NSDate date];
[datePicker addTarget:self action:@selector(LabelChange:)forControlEvents:UIControlEventValueChanged];
[self.view addSubview:datePicker];
[datePicker release];
Change region to United states i.e locale settings
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"US"];
[datePicker setLocale:locale];
In iOS 5.1 display UIDatePicker
as it is in 4.3
Your and mine both of code is same but in my application UIDatePicker display
with MM-dd-yyyy
Use it ...may be helpful for you.
self.DatePicker= [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 320, 216)];
self.DatePicker.datePickerMode = UIDatePickerModeDate;
[self.DatePicker addTarget:self
action:@selector(SetDatePickerTime:)
forControlEvents:UIControlEventValueChanged];
[self.asheet addSubview:self.DatePicker];
My all code works is fine,
Problem is with Settings,
My region format is set to india and change it to United state,
All works fine.....