nsdate - Compare time in string and subtract 10 min from that in iphone? -


i have array of time string "10:10:12","12:10:34","05:23:11" this. want calculate less(min) time form array i.e "05:23:11" , subtract 10 min that. , save result in same format. please if 1 knows how me. appreciate him/her. thank in advance.

if array dates big u can llike this:

    nsarray * arraywithtime = [nsarray array];     nsdateformatter *dateformatter = [[nsdateformatter alloc] init];    [dateformatter setdateformat:@"hh:mm:ss"];   nssortdescriptor *d = [[nssortdescriptor alloc] initwithkey:nil ascending:yes comparator:^nscomparisonresult(id obj1,id obj2){    nsdate *date1 = [dateformatter datefromstring:obj1]; nsdate *date2 = [dateformatter datefromstring:obj2];  return [date1 compare:date2];} ];  nsarray * comparators = [nsarray arraywithobject:d]; nsarray * final = [arraywithtime sortedarrayusingdescriptors:comparators]; 

then take first item in final array , subtract 10 min


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -