title: Get NSDate and convert it from the 24 hour format to 12 hour format in swift
body: <p>I've seen this post for other languages but not for swift. I have a date saved in the format of <code>2015-08-31 21:36:00 +0000</code> and I'm able to extract the day, month, year and weekday with the code below to produce <code>Monday, August 31, 2015</code>. When I try to use:</p>
  
  <pre><code>let hourInt = components.hour
  var hourString = String(hourInt)
  </code></pre>
  
  <p>It prints a four hour difference. In this case "17" for the "21". How do I
  display it as <code>9:36 P.M.</code>?     </p>
  
  <pre><code>let flags: NSCalendarUnit =  NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour |  NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekday | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear
  let date = NSDate()
  let dateFormatter: NSDateFormatter = NSDateFormatter()
  let components = NSCalendar.currentCalendar().components(flags, fromDate: array.date)
  
  
  let weekday = components.weekday
  let weekdays = dateFormatter.weekdaySymbols
  let weekdayString = weekdays[weekday-1] as! String
  
  let month = components.month
  let months = dateFormatter.monthSymbols
  let monthString = months[month-1] as! String
  
  let dayInt = components.day
  var dayString = String(dayInt)
  
  let year = components.year
  let yearString = String(year)
  println(weekdayString + ", " + monthString + " " + dayString + ", " + yearString)
  </code></pre>