I want to check if the current NSDate
is 2 Weeks ahead of the another NSDate
. I have can do somethings as below code but was wondering if there is any proper way to do.
[calendar rangeOfUnit:NSCalendarUnitDay startDate:¤tDate interval:NULL forDate:currentDate];
[calendar rangeOfUnit:NSCalendarUnitDay startDate:&previousDate interval:NULL forDate:previousDate];
NSDateComponents *difference = [calendar components:NSCalendarUnitDay fromDate:previousDate toDate:currentDate options:0];
if(diiference >= 14) {
}
You can use one trick here. First calculate number of days between 2 dates and then calculate number of weeks between them. You can do it like
You can use
CGFloat
if you want to get week value like 1.5 and keep as it is if you want week count like 1,2,3,etc