obj-c : iphone programming NSTimeInterval problem
- by the1nz4ne
hi, i got a problem with my time interval. I need to get the interval of two times in this format : HH:MM. If i enter : 15:35 and 16:35 it is ok, but when i do 20:30 to 01:30, it gives me like 18 hours interval.. anyone have an idea?
NSString *startDate= starthere.text;
NSString *endDate = endhere.text;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm"];
NSDate *dateSelected = [dateFormatter dateFromString:startDate];
NSDate *dateSelected2 = [dateFormatter dateFromString:endDate];
[dateFormatter release];
interval = [dateSelected2 timeIntervalSinceDate:dateSelected];