Possible Duplicate:
How to Get time difference in iPhone
I´m getting date and time from a JSON feed. I need to find the difference between the date I´m getting from the feed and today´s date and time. Any suggestions how I can do this?
I know I need to subtract the current date with the date I get from the feed, but I don´t know how to do it.
Ex:
Date from feed: Date: 2011-06-10 15:00:00 +0000
Today: Date: 2011-06-10 14:50:00 +0000
I need to display that the difference is ten minutes.
Thanks!
Create two NSDate objects from the strings using NSDate's -dateWithString:
, then get the difference of the two NSdate objects using
NSTimeInterval diff = [date2 timeIntervalSinceDate:date1];