title: UIDatePicker with 2 Textfields (from/until date)?
body: <p>I have a DatePicker. I wanna let the User choose the date and time in "from"textfield (which starts at tomorrow at 9 am) and then a textfield "until" ( which starts 1.5 hours later).</p>
  
  <p><a href="http://i42.tinypic.com/r7kb5e.jpg" rel="nofollow">From TextFiled</a>  <a href="http://i40.tinypic.com/akev06.jpg" rel="nofollow">Until TextField</a></p>
  
  <p>For Example. "From" TextField: 25.04.2012 09:00,  "Until" TextField: 25.04.2012 10:30</p>
  
  <p>Take a look at the picture, which i have uploaded.</p>
  
  <p>Everything works fine so far, but if i click on the "until" textfield the Datepicker did not set the correct Date and Time. He Set 25.04.2012 09:00 instead of 25.04.2012 10:30</p>
  
  <p>My Code so far:</p>
  
  <pre><code>ViewDidLoad:
  
      //Create DatePicker
  
      self.thePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 152, 325, 300)];
      self.thePicker.datePickerMode = UIDatePickerModeDateAndTime;
      [thePicker addTarget:self action:@selector(dateChanged) forControlEvents:UIControlEventValueChanged];
  
  
      //Set DatePicker to Tomorrow 9:00 o'clock
  
      NSDate *today = [NSDate date];
  
      NSCalendar *german = [[NSCalendar alloc]          initWithCalendarIdentifier:NSGregorianCalendar];
  
      [german setLocale:[NSLocale currentLocale]];
      NSDateComponents *nowComponents = [german components:NSYearCalendarUnit |  NSWeekCalendarUnit | NSHourCalendarUnit | NSDayCalendarUnit| NSMonthCalendarUnit| NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:today];
  
      [nowComponents setDay:[nowComponents day] +1]; 
      [nowComponents setWeek: [nowComponents week]]; 
      [nowComponents setHour:9];
      [nowComponents setMinute:0];
      [nowComponents setSecond:0];
  
      NSDate *beginningOfWeek = [german dateFromComponents:nowComponents];
      NSDate *pickereinstelldate= beginningOfWeek;
  
      [self.thePicker setDate:pickereinstelldate];
  
  
      //Set DatePicker to correct Format
      NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
      [dateFormatter setDateFormat:@"dd.MM.yyyy  HH:mm"];
      NSString *datum =[dateFormatter stringFromDate:self.thePicker.date];
  
      //set the date at textfield "bis" to 1.5 hours later
      NSDate *morgenDate = [beginningOfWeek dateByAddingTimeInterval:3600*1.5];
      NSString  *newdate = [dateFormatter stringFromDate:morgenDate];
  
      //Set the until TextField with the newdate
  
       tfVon.text=datum;
      tfBis.text=newdate; 
  
  
      [self.view addSubview:thePicker];
      self.thePicker.hidden=YES;
      tfVon.inputView=thePicker;
      tfBis.inputView=thePicker;
  
  
  }
  </code></pre>
  
  <p>The Action function:</p>
  
  <pre><code>    -(IBAction)dateChanged
      {
      self.date = [thePicker date];
      NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
      [dateFormatter setDateFormat:@"dd.MM.yyyy  HH:mm"];
      NSString *datum =[dateFormatter stringFromDate:self.date];
      NSDate *neuesdatum = [date dateByAddingTimeInterval:3600*1.5];
      NSString *neuesd = [dateFormatter stringFromDate:neuesdatum];
  
     //when i click on "From" textfield
      if (dateBOOL==YES)
  
      {
          tfVon.text=datum;
  
          tfBis.text=neuesd;
  
      }
          //when i click on "Until" textfield
          if (dateBOOL==NO) {
          tfBis.text=neuesd;
  
          }    
  
  }
  </code></pre>
  
  <p>here is where i set my datebool to no:</p>
  
  <pre><code>    -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
      {
  
  
      if (textField==tfVon)
      {
  
          dateBOOL=YES;
          self.thePicker.hidden=NO;
  
          return YES;
      }
      if (textField==tfBis)
      {
  
          dateBOOL=NO;
          self.thePicker.hidden=NO;
          return YES;
      }
  
      }
     return YES;
  
      }
  </code></pre>
  
  <p>Is There a way that i can set the DatePicker in "Until" TextField to the correct Time?</p>