title: NSDate is null after being set
body: <p>I have the following code that is supposed to convert an <code>NSString</code> into an <code>NSdate</code>:</p>
  
  <pre><code>    NSString *dateStr = self.currentElement;
      NSLog(@"Raw date string: %@", dateStr);
  
      // Convert string to date object
      NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
      [dateFormat setDateFormat:@"MM/dd/yyyy"];
      NSDate *date = [dateFormat dateFromString:dateStr];
      NSLog(@"%@", date);
  </code></pre>
  
  <p>That produces the following output:</p>
  
  <pre><code>Raw date string: 7/8/1806 12:00:00 AM
  (null)
  </code></pre>
  
  <p>I am not sure why <code>*date</code> is still <code>null</code> right after I set it with <code>dateFromString</code>. What would cause this?</p>
  
  <p>edit: after looking at the duplicate question, I changed my code to the following: </p>
  
  <pre><code>    NSString *dateStr = self.currentElement;
      NSLog(@"Raw date string: %@", dateStr);
  
      // Convert string to date object
      NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
      [dateFormat setDateFormat:@"MM/dd/yyyy hh:mm:ss a"];
      NSDate *date = [dateFormat dateFromString:dateStr];
      NSLog(@"%@", date);
  </code></pre>
  
  <p>Which now produces the following output: </p>
  
  <pre><code>Raw date string: 7/8/1806 12:00:00 AM
  1806-07-08 04:56:02 +0000
  </code></pre>
  
  <p>Why is the <code>NSdate</code> printing incorrectly even when it is using the exact same <code>NSDateFormatter</code> that I just used to make it?</p>