title: How to convert timestamp in seconds with hour offset to local iOS NSDate?
body: <p>Im trying to convert a timestamp in seconds since 01/01/1970 with an hour timezone offset (i.e. -6) to a local NSDate. Here is what i have so far:</p>
  
  <pre><code>    NSInteger startTime = 1312228800;
      NStInteger startTimeOffset = -6;
      NSDate *startTimeDate = [NSDate dateWithTimeIntervalSince1970:startTime];
  
      NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
      [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss ZZZZ"];
      [dateFormatter setLocale:[NSLocale currentLocale]];        
  
      NSInteger gmtOffset = [startTimeOffset intValue]*60*60;
      [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:gmtOffset]];        
      NSDate *newStartTimeDate = [dateFormatter dateFromString:[dateFormatter stringFromDate:startTimeDate]];
  </code></pre>
  
  <p>For example if i have the time of 1312228800 i get 08/01/2011 20:00 at GMT 0. The actual startTime is 08/01/2011 14:00 at GMT -6. However locally on the device if i am based in EST the startTime should be set to 08/01/2011 16:00 GMT -4.</p>
  
  <p>However i just get back the same startTime with no offset taken into account which is 08/01/2011 20:00 in the example above. </p>
  
  <p>Any ideas where im going wrong here, have a feeling its got something to do with the setDateFormat: argument?</p>
  
  <p>thx</p>