so in my app I want to subtract two dates. The first date is set date and the second one is the current date. So i tried this code:
NSString *setDateString = [NSString stringWithFormat:@"12:30"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSDate *setDate = [dateFormatter dateFromString:setDateString];
NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:setDate];
But it counts the interval from 1970. But I need from the current day. Can anyone help?
I assume you want the difference between now and 1230 hrs of today. This can be done by
The reason it doesn’t work for you is you’ve not given the format correctly. Alternatively, you can describe it correctly in
setDateStringby specifying all the components rather than just hour and minute.