NSDateFormatter

Here’s how to use NSDateFormatter to set the text in a UITableViewCell with today’s date using NSDate:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
    cell.detailTextLabel.text = [NSString stringWithFormat:@"When: %@", [dateFormatter stringFromDate:[Date date]]];

Leave a Reply

Your email address will not be published. Required fields are marked *