obj-c : iphone programming NSTimeInterval problem

Posted by the1nz4ne on Stack Overflow See other posts from Stack Overflow or by the1nz4ne
Published on 2010-06-16T16:48:59Z Indexed on 2010/06/16 16:52 UTC
Read the original article Hit count: 293

Filed under:
|

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];

© Stack Overflow or respective owner

Related posts about time

Related posts about interval