//Create a Date Picker
[self.view addSubview:datePicker];
-(void)dateChanged1
{
NSDateFormatter *df=[[NSDateFormatter alloc]init];
[df setFormatterBehavior:NSDateFormatterBehavior10_4];
[df setDateFormat:@"MM/dd/yyyy"];
txt1.text = [NSString stringWithFormat:@"%@",
[df stringFromDate:datePicker.date]];
[df release];
}
theDatePicker1 = [[UIDatePicker alloc] initWithFrame:CGRectMake(0.0,140.0, 320.0, 120.0)];
theDatePicker1.transform = CGAffineTransformMakeScale(1.0, 0.8); theDatePicker1.datePickerMode = UIDatePickerModeDate;
self.datePicker = theDatePicker1;
[theDatePicker1 release];
[datePicker addTarget:self
theDatePicker1.transform = CGAffineTransformMakeScale(1.0, 0.8); theDatePicker1.datePickerMode = UIDatePickerModeDate;
self.datePicker = theDatePicker1;
[theDatePicker1 release];
[datePicker addTarget:self
action:@selector(dateChanged1)
forControlEvents:UIControlEventValueChanged];
[self.view addSubview:datePicker];
//Date Picker Hide the Past Dates Coding
NSDate *now = [[NSDate alloc] init];
now = [now addTimeInterval:60*60];
NSLog(@"%@",now);
theDatePicker1.minimumDate = now;
now = [now addTimeInterval:60*60];
NSLog(@"%@",now);
theDatePicker1.minimumDate = now;
// Date Format Coding
-(void)dateChanged1
{
NSDateFormatter *df=[[NSDateFormatter alloc]init];
[df setFormatterBehavior:NSDateFormatterBehavior10_4];
[df setDateFormat:@"MM/dd/yyyy"];
txt1.text = [NSString stringWithFormat:@"%@",
[df stringFromDate:datePicker.date]];
[df release];
}