I have 2 arrays with time values in it. They are in the following format. mm:ss:hundreds of a sec. I want to get the difference between the two [lastObjects] in the arrays. NSDate is not working because the last value is in hundredsth of a sec.
A question. If the second date is larger than the first will it give me a negative number like -01:10:00 ?
Use the Clock App To do so, open the Clock app on your iPhone or iPad and go to the “World Clock” tab. Here, tap the plus sign (+) in the top toolbar. Search for the city, and then tap it in the list to add it to the World Clock section. You now see the current time for that city in the World Clock section.
If you want to double check that your iPhone does, indeed, automatically change for daylight savings, you can do so easily in a matter of minutes. Head to your phone's Settings, then General, then Date & Time. The Set Automatically toggle should be switched on (so, you should see a green color).
On Sunday, March 13, at 2 a.m. local time, the clock on every smartphone in the United States will adjust — or not adjust — to daylight saving time according to the time observed in your region, without your having to tap a finger.
On an iPhone, you can add multiple cities/countries in the clock section but opening the clock app and then the World Clock section every time can be a pain. The free Klok app makes things simpler by adding multiple time zones into a widget.
Your problem has two parts, parsing the time and getting the difference:
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
[dateFormatter setDateFormat:@"mm:ss:SS"];
NSDate* firstDate = [dateFormatter dateFromString:@"01:00:00"];
NSDate* secondDate = [dateFormatter dateFromString:@"01:02:00"];
NSTimeInterval timeDifference = [secondDate timeIntervalSinceDate:firstDate];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With