NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
[dateFormatter setDateFormat:@"hh:mm:ss"];
NSDate* firstDate = [dateFormatter dateFromString:starttime];
NSDate* secondDate = [dateFormatter dateFromString:endtime];
NSTimeInterval ti = [secondDate timeIntervalSinceDate:firstDate];
//NSString *str1 = [NSString stringWithFormat:@"%d",ti];
//NSLog(@"str1 %@",str1);
NSUInteger h, m, s;
h = (ti / 3600);
m = ((NSUInteger)(ti / 60)) % 60;
s = ((NSUInteger) ti) % 60;
NSString *str = [NSString stringWithFormat:@"%d:%02d:%02d", h, m, s];
//NSLog(@" strdiff : %@ ",str);
No comments:
Post a Comment