I'm trying to determine if the user set a date picker to a day less than today. E.g, today is 4/23/17, so I want to detect if the user does like 4/15/17 or like 2/4/17. Basically anything less than the date. I'm kind of stuck. If you know how to do it, please help.
            Asked
            
        
        
            Active
            
        
            Viewed 52 times
        
    -1
            
            
        - 
                    `NSCalendar` provides a lot of methods to do date math. – vadian Apr 23 '17 at 16:51
 - 
                    Have you looked at the documentation for `NSDate`? What trouble exactly are you having? [Edit] your question with relevant code. – rmaddy Apr 23 '17 at 17:04
 - 
                    1You can use: if( [firstDate timeIntervalSinceDate:secondDate] > 0 ) { //Do your stuff} – IPS Brar Apr 23 '17 at 17:05
 - 
                    @IPSBrar Why not simply compare the two date objects with the `compare:` method? – rmaddy Apr 23 '17 at 17:06
 - 
                    1@rmaddy there are a lot of methods to do so, I used what I think is the easiest. – IPS Brar Apr 23 '17 at 17:07
 
1 Answers
0
            
            
        NSDate *date1 = [NSDate date];
NSDate *date2 = [NSDate date];
if([date1 compare:date2] == NSOrderedAscending)
{
}
        nspavlo
        
- 377
 - 3
 - 12
 
- 
                    Code only answers are low quality and candidates for deletion, there should always be at least 1 or 2 sentences explaining what part of the question you are answering. – Eric Leschinski Apr 24 '17 at 03:42