title: NSDateFormatter - Trouble Parsing Date from Twitter JSON API
body: <p>I'm trying to convert a string from a Twitter API result into an NSDate object using NSDateFormatter. What I'm finding is that the NSDateFormatter is just returning the current date/time of my machine instead. Any help would be greatly appreciated!</p>
  
  <p>Here's what the string looks like coming into my function: </p>
  
  <blockquote>
    <p>Sat, 11 Dec 2010 01:35:52 +0000</p>
  </blockquote>
  
  <p>And here's the function:</p>
  
  <pre><code>+(NSDate*)convertTwitterDateToNSDate:(NSString*)created_at
  {
      // Sat, 11 Dec 2010 01:35:52 +0000
      static NSDateFormatter* df = nil;
  
      df = [[NSDateFormatter alloc] init];
      [df setTimeStyle:NSDateFormatterFullStyle];
      [df setFormatterBehavior:NSDateFormatterBehavior10_4];
      [df setDateFormat:@"EEE, d LLL yyyy HH:mm:ss Z"];
  
      NSDate* convertedDate = [df dateFromString:created_at];     
      [df release];
  
      return convertedDate;
  }
  </code></pre>
  
  <p>And here's the date returned:</p>
  
  <blockquote>
    <p>2010-12-10 17:58:26 -0800</p>
  </blockquote>
  
  <p>Which happens to be the date and time of my computer right now.</p>
  
  <p>*<strong><em>Note!</em>*</strong> changed memory management from using an autorelease when allocating the DateFormater, to an explicit release in the function. When calling this in a giant loop, I found that it started failing with the autorelease (I'm guessing the auto part wasn't releasing fast enough), but changing it to this fixed the problem.</p>