title: iOS: Get localised hour from NSDate
body: <p>How to get localized hours only from NSDate respective to 12 hr/24 hr time is set by the user on device?
  Consider date is "3 Jun 2015 3:00PM"
  If 12 hour format is set then it should show 3PM (excluding minutes part)
  If 24 hour format is set then it should show 15 (excluding minutes part)</p>
  
  <p>I have tried with following without success on all locales. For example it is working perfect for de_DE &amp; fr_FR but for en_US it always returns 3 without AM/PM.</p>
  
  <pre><code>NSDateFormatter *dateFormatter = [NSDateFormatter new];
  NSString *localeFormatString = [NSDateFormatter dateFormatFromTemplate:@"HH" options:0 locale:dateFormatter.locale];
  dateFormatter.dateFormat = localeFormatString;
  dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
  
  NSString * hour = [dateFormatter stringFromDate:date];
  NSLog(@"%@",hour);
  </code></pre>
  
  <p>P.S.
  If I get the time string (hours &amp; minutes both) using following code, it works perfectly with respect to locale as well as 12/24 hour time format. However I want to get only hours and this is not achieved with 12/24 hour time format.</p>
  
  <pre><code>  NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
    timeFormatter.timeStyle = NSDateFormatterShortStyle;
    timeFormatter.dateFormat = NSDateFormatterNoStyle;
    timeFormatter.AMSymbol = @"a";
    timeFormatter.PMSymbol = @"p";
  
    timeFormatter.timeZone = timeZone;
    return [timeFormatter stringFromDate:date];
  </code></pre>