title: UIDatePicker giving wrong time
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8466744/getting-date-from-nsdate-date-off-by-a-few-hours">Getting date from [NSDate date] off by a few hours</a><br>
    <a href="https://stackoverflow.com/questions/14082912/nsdate-date-dont-give-me-the-right-hour">NSDate date don’t give me the right hour</a>  </p>
  </blockquote>
  
  
  
  <p>I have this piece of code:</p>
  
  <pre><code>NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  [formatter setDateFormat:@"HH:mm"];
  
  NSString *formattedDateInString = [formatter stringFromDate:[self.datePicker date]];
  NSLog(@"This is the formatted date (STRING) ---&gt; %@" ,formattedDateInString);
  self.fromHourLabel.text = formattedDateInString;
  
  NSDate *date = [formatter dateFromString:formattedDateInString];
  NSLog(@"This is the date (NSDate) ---&gt; %@" ,date);
  self.fromHour = date;
  </code></pre>
  
  <p>I basically get the date from a UIDatePicker, set Hours and Minutes as a label text and save the date into a property called fromHour. In the <code>-viewDidLoad</code> method I also have:</p>
  
  <pre><code>self.datePicker.timeZone = [NSTimeZone localTimeZone];
  </code></pre>
  
  <p>This is the output:</p>
  
  <p><img src="https://i.stack.imgur.com/wFHoB.png" alt="enter image description here"></p>
  
  <p>as you can see, with this code, I have two main problems:</p>
  
  <ul>
  <li>The first output say 17.30 and the second 16:30 (the first output is correct, the second is wrong) why?</li>
  <li>The second output is formatted with "yyyy-MM-dd HH:mm:ss" but I need only "HH:mm".</li>
  </ul>
  
  <p>Can you help me?</p>