views:

48

answers:

1

How can I compare two NSDates and return the amount of time between them.

For example:

2010-06-20 14:29:41 -0400
2010-06-20 14:53:29 -0400

should return something like: 23 or 24(minutes), rounding the seconds because I don't really need the seconds.

+2  A: 

try something like:

int intervall = (int) [date1 timeIntervalSinceDate: date2] / 60;
phonecoddy
works great. Thanks a bunch.
Matt S.
Note that this may evaluate to a negative number of minutes, depending on which date is earlier. Either negate the number if it is negative, or use the `abs` or `fabs` function.
Peter Hosey
thanks as always for that tip @Peter
Matt S.