title: what is the best way to test NSDate Comparison?
body: <p>I have two datepickers that gives me a startTime and an endTime. according to this code:</p>
  
  <pre><code>NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
  dateFormatter.timeZone=[NSTimeZone defaultTimeZone];
  dateFormatter.timeStyle=NSDateFormatterShortStyle;
  dateFormatter.dateStyle=NSDateFormatterShortStyle;
  NSString *dateTimeString=[dateFormatter stringFromDate:startTime.date];
  NSLog(@"Start time is %@",dateTimeString);
  
  
  NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc]init];
  dateFormatter2.timeZone=[NSTimeZone defaultTimeZone];
  dateFormatter2.timeStyle=NSDateFormatterShortStyle;
  dateFormatter2.dateStyle=NSDateFormatterShortStyle;
  NSString *dateTimeString2=[dateFormatter2 stringFromDate:endTime.date];
  NSLog(@"End time is %@",dateTimeString2);
  </code></pre>
  
  <p><strong>in my .h</strong></p>
  
  <pre><code>@property (weak, nonatomic) IBOutlet UIDatePicker *startTime;
  @property (weak, nonatomic) IBOutlet UIDatePicker *endTime;
  </code></pre>
  
  <p>and I have this code that let me compare between the giving time and current time. What is the best way to test it as I need to you use it in the background.</p>
  
  <pre><code>if ([[NSDate date] isEqualToDate:startTime.date]) {
  NSLog(@"currentDate is equal to startTime"); 
  }
  
  if ([[NSDate date] isEqualToDate:endTime.date]) {
  NSLog(@"currentDate is equal to endTime"); 
  }
  </code></pre>
  
  <p>I need to choose between that code or this one. so would <code>NSLog</code> work ok here?</p>
  
  <pre><code>- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate
  
  
  if([startTime.date timeIntervalSinceDate:[NSDate date]] &gt; 0)
  {
  //start time greater than today
  }
  
  else if([startTime.date timeIntervalSinceDate:[NSDate date]] &lt; 0)
  {
  //start time less than today
  }
  
  else
  {
  //both dates are equal
  }
  </code></pre>
  
  <p>Thanks</p>