0

I need a function which receives [NSDate date] and a string @"2010-11-12" and returns the amount of days between those two dates.

More explanation: I need to store a date from a server in the format @"2010-11-12" in my NSUserdefaults. The meaning of this date is the expireDate of a feature in an iPhone App. Every time I press on a button for this feature I need to check if the difference in days between the current time->[NSDate date] and @"2010-11-12" is greater than 0. That means that the feature is disabled.

It's making me crazy, maybe it's dead simple.

grobald
  • 155
  • 2
  • 14
  • I [answered this here](http://stackoverflow.com/questions/4575689/objective-c-calculating-the-number-of-days-between-two-dates/4575770#4575770). – Abizern Jan 02 '11 at 18:47
  • possible duplicate of [Number of days between two NSDates](http://stackoverflow.com/questions/4739483/number-of-days-between-two-nsdates) – John Conde Jul 27 '12 at 02:22

1 Answers1

0

Use an NSDateFormatter to convert the string to an NSDate - then compare the date objects.

Brad
  • 11,262
  • 8
  • 55
  • 74