tags:

views:

84

answers:

1

Hello,

I am working on a simple to do list application, and I am wanting to set the date in a normal format in the titleForHeaderInSection part of my uiTableView. But I am having some issues. It works to an extent, but is giving me way too much information, it shows:

2009-12-01 00:04:10 -0700

in the field where I'd just like it to show the date that the item was created, and ideally in a more normal format, without the specific time. Can you please help me figure out what I need to change? Thanks!!

A: 

You can use NSDateFormatter:

NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"HH:mm 'on' EEEE MMMM d"];
NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]];

NSLog(@"newDateString %@", newDateString);
// For US English, the output is:
// newDateString 10:30 on Sunday July 11

You should also read Date Formatting Programming Guide

notnoop