I am trying to add 60 days from the current date in milliseconds. I tried the below code, i’m able to get the current date milliseconds properly, but after adding 60 days milliseconds to current date, its not giving me the expected milliseconds. Please help on correcting what i’m doing wrong here.
double currDateInMilliSecs = [NSDate timeIntervalSinceReferenceDate] * 1000;
NSLog(@"currDateInMilliSecs: %f", currDateInMilliSecs);
double sixtydaysvalue = 60 * 24 * 3600 * 1000;
NSLog(@"sixtydaysvalue: %f", sixtydaysvalue);
double sixtyDaysMilliSecsFromCurrDate = currDateInMilliSecs + sixtydaysvalue;
NSLog(@"sixtyDaysMilliSecsFromCurrDate: %f", sixtyDaysMilliSecsFromCurrDate);
Thank you.
Try
The value exceeds the max 32-bit int, so you need to perform the calculation in the
doubletype.