how do I get the number hours between two times?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4235635/operation-between-hours">Operation between hours.</a>  </p>
</blockquote>



<p>I have 2 buttons if you press each one will come out time picker and return the time chosen in the button. How do I subtract the two times?
I try to explain it with and example:
I press button one, and I have time picker coming out, I choose lets say 6:00pm. 6:00pm will return in my button1.
I do the same thing with button two. I choose a time lets say 8:00pm. 8:00pm will return in my button2.
I would like to know how can I subtract them to find how many hours I have between button1 and button2. In this case would be 2 hours.</p>

<p>Here is a piece of code where I press the done button to return the time chosen in the button.</p>

<pre><code>- (IBAction)doneButtonPressed2:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(datePickerViewController2:didChooseDate:)]) {
        NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
        [dateFormatter setTimeStyle:NSDateFormatterShortStyle];

        NSString *dateString = [dateFormatter stringFromDate:[datePicker date]];

        [self.delegate datePickerViewController2:self didChooseDate:dateString];
        [self dismissModalViewControllerAnimated:YES];      
    }
</code></pre>

<p>I believe I have to use this to have what I want:</p>

<pre><code>//NSTimeInterval secondsBetween = [firstTime timeIntervalSinceDate:secondTime];
</code></pre>

<p>but I am not quite sure how to use it. </p>

<p>Thank you very much for your help!</p>
