title: 24 hour time from date string
body: <p>I am trying to get just the time and that too in 24 hour format from following string :  </p>
  
  <p><strong>7/2/2015 2:30:00 PM</strong>  </p>
  
  <p>This is what I have tried :  </p>
  
  <pre><code>-(NSString*)returnDate:(NSString*)dateString
  {
  
      NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
      [dateFormatter1 setDateFormat:@"MM/dd/yyyy hh:mm:ss aaa"];
      NSDate *date = [dateFormatter1 dateFromString:dateString];
  
     dateString = [date descriptionWithLocale:[NSLocale systemLocale]];
  
  
  
      NSTimeZone *currentTimeZone = [NSTimeZone localTimeZone];
      NSTimeZone *utcTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
  
      NSInteger currentGMTOffset = [currentTimeZone secondsFromGMTForDate:date];
      NSInteger gmtOffset = [utcTimeZone secondsFromGMTForDate:date];
      NSTimeInterval gmtInterval = currentGMTOffset - gmtOffset;
  
      NSDate *destinationDate = [[NSDate alloc] initWithTimeInterval:gmtInterval sinceDate:date];
  
      NSDateFormatter *dateFormatters = [[NSDateFormatter alloc] init];
      [dateFormatters setDateFormat:@"HH:mm a"];
      [dateFormatters setDateStyle:NSDateFormatterShortStyle];
      [dateFormatters setTimeStyle:NSDateFormatterShortStyle];
      [dateFormatters setDoesRelativeDateFormatting:YES];
      [dateFormatters setTimeZone:[NSTimeZone systemTimeZone]];
      dateString = [dateFormatters stringFromDate: destinationDate];
  
      return dateString;
  }
  </code></pre>
  
  <p><strong>Output : 4:30</strong></p>
  
  <p>This is returning correct time but in 12 hour format. I want the time in 24 hour format.  </p>
  
  <p><strong>Desired output : 16:30</strong></p>