I'm calculating the duration time between a startTime and endTime and am using the following code to get the time interval between two NSDates
NSTimeInterval duration = [self.endTime timeIntervalSinceDate:self.startTime];
NSLog(@"interval: %f", duration);
However, the NSLog statement tells me that the duration is wrong. The dates are derived from a datePicker. For example, when I set the start date to Jun 19, 2013 9:15pm and end date to Jun 19, 2013, 2013 916pm (one minute later), the duration logged is 15.00000 instead of 60.00000.
Why is this? How can I get the correct duration between two dates?
EDIT
I did some more logging and logged the start date and the end time. Here's the NSLog statement
NSLog(@"interval: %f for %@ to %@", duration, self.startTime, self.endTime);
and here's what gets logged:
interval: 15.000000 for 2013-06-19 04:52:45 +0000 to 2013-06-19 04:53:00 +0000
For some reason the start date from the datePicker is setting the seconds to 45 even though the date picker just says 4:52. How can I fix this?
Also, as a note, the same datePicker is used to choose both dates if that matters at all.