tags:

views:

20

answers:

1

hi, all, I want know the passed time that also is between two date,

for example , dateTime1 and dateTime2 , I want a function like getPassedTime( time1, time2)

the function result should be like '1 day 3 hours 12 minutes 10 second' or just '40 second' ...

I know that the method 'timeIntervalSinceDate' of the class 'NSDate' can be use , but the problem is convert to details string that could be easy understand ....

anyone can help ? share some code will be appreciate or give me some tip if possible.

Thanks.

Regards

A: 

Look at NSCalendar:

- (NSDateComponents *)components:(NSUInteger)unitFlags fromDate:(NSDate *)startingDate toDate:(NSDate *)resultDate options:(NSUInteger)opts;

You will still have to decide which components to display, but they will be broken out by unit.

drawnonward