title: Time Interval between two dates returns nil
body: <p>I am calculating the time difference between two NSDates and it always returns 0.0000 .I am using the Same logic to calculate the time stamp and have formatted correctly as well .. When I try to log the dates separately , it gets printed correctly and when I print the difference, It prints 0.0000... Here's the code to calculate the date ..</p>
  
  <pre><code>-(NSDate *) toLocalTime
  {
  NSTimeZone *tz = [NSTimeZone defaultTimeZone];
  NSInteger seconds = [tz secondsFromGMTForDate: [NSDate date]];
  return [NSDate dateWithTimeInterval: seconds sinceDate: [NSDate date]];
  }
  </code></pre>
  
  <p>and here's the code where I find the difference..</p>
  
  <pre><code>NSLog(@"the time when the location was updated is %@",timeWhenTheLocationWasUpdated);
  NSLog(@"the time when the server was contacted last time was %@",timeWhenLastLocationPosted);
  
  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"dd-MM-yyyy HH:mm:ss ZZZ"];
  NSDate *timeofUpdatingLocation = [[NSDate alloc] init];
  NSDate *timeofPostingToTheServer = [[NSDate alloc]init];
  timeofUpdatingLocation = [dateFormatter dateFromString:timeWhenTheLocationWasUpdated];
  timeofPostingToTheServer = [dateFormatter dateFromString:timeWhenLastLocationPosted];
  NSTimeInterval difference = [timeofPostingToTheServer timeIntervalSinceDate:timeofUpdatingLocation];
  NSLog(@"the difference between posting the location to the server and updating the location is %f",difference);
  </code></pre>
  
  <p>Both the NSlog's in the beginning of the code prints the date in the format mentioned in the date formatter correctly.</p>