title: How to display time in 12 hour format in Objective-C?
body: <p>I was working on an iPhone application, and I need to display the time in a label. So I wrote the follow:</p>
  
  <pre><code>NSDate *date = [NSDate date];
  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"HH:mm a"];
  NSString *formattedDateString = [dateFormatter stringFromDate:date];
  timeLabel.text = formattedDateString;**
  </code></pre>
  
  <p>It displays time in label but in 24H format.</p>
  
  <ul>
  <li>Example: 15.00 PM instead of 3.00 PM</li>
  </ul>
  
  <p>I want to display time in 12h format, i.e. 3.00 PM</p>
  
  <p>What should I do?</p>
  
  <p>Thanks in advance.</p>