0

I have a UIDatePicker which spits the selected date to a label using the following:

-(void)updateLabel:(id)sender {

    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    df.dateStyle = NSDateFormatterLongStyle;
    df.timeStyle = NSDateFormatterMediumStyle;
    self.dateLabel.textColor = [UIColor darkGrayColor];
    self.dateLabel.text = [NSString stringWithFormat:@"%@",[df stringFromDate:self.datePicker.date]];
}

Using df.timeStyle = NSDateFormatterLongStyle, which seems to be the only option which includes timezone I get this output:

March 5, 2016, at 2:37:33 PM, MST

However, I don't want the seconds there. This is the output I am trying to achieve:

Match 5, 2016 at 2:37PM, MST

Can someone help a brother out!

Adam G
  • 1,068
  • 9
  • 21
  • 1
    try to format as per ur requirement instead of using long style. Please look at this: https://gist.github.com/romaonthego/5138532 – Teja Nandamuri Mar 03 '16 at 21:18
  • NSDateFormatter will use whatever format you want; just use `setDateFormat:` and the appropriate format string. – jscs Mar 03 '16 at 21:26

0 Answers0