I have 2 labels that I set to the current time using the following code:
NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@"hh:mma"];
time2.text = [dateformatter stringFromDate:[NSDate date]];
[dateformatter release];
labelCount++;
When a button is clicked label one will change to the current time, when button is click again label 2 will change to the current time but I want to be able to change a third label to display the difference between these times. Any help/guidance would be greatly appreciated.
[date2 timeIntervalSinceDate:date1] will give you the time interval in seconds, but if you want the difference displayed as hours:minutes then this will work too.
}
Note: if you aren’t using arc then you’ll need to add the appropriate releases to this code.