0

Maybe i am missing something very stupid so forgive me . Comparing a date that is 1 month later than another date , starts to give me strange numbers. I guess its because the result is float ? Here is how i do the comparison :

    int daysToCheckUses=60;
    long seconds=60*60*24*daysToCheckUses;
    NSDate *today=[NSDate date];
        if([today timeIntervalSinceDate:date]>seconds) //date can be more than 60 days old

Is there something wrong with this,when using big numbers? for example when the interval is 1 month i get 518400,but for 3 months i get 18662400000 i know that the comparisons returns float number that can't hold these numbers. I am afraid also to get a crash when a few months will pass.

Curnelious
  • 1
  • 16
  • 76
  • 150

1 Answers1

1

This method to calculate a big distance is not that good, i found a great and better way for this using a great answer from here :

Number of days between two NSDates

Where the comparison is for days, than months will only give a few 100's integer .

Community
  • 1
  • 1
Curnelious
  • 1
  • 16
  • 76
  • 150