Quote:
Originally Posted by franzwarning
Code:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM-dd-yyyy"];
NSDate *now = [[NSDate alloc] init];
NSString *theDate = [dateFormat stringFromDate:now];
NSLog(@"\n"
"theDate: |%@| \n"
, theDate);
dateOfToday.text = theDate;
[dateFormat release];
[now release];
Ok so i've got this code that prints the date as "12-05-2010"
How could I have it displayed as December 05 2010?
Cheers,
George
|
Instead of an explicit format string, why not use the setDateStyle method:
[dateFormat setDateStyle: NSDateFormatterLongStyle];
For a US locale, that should give the format you want. If the user is in another locale, it will adapt automatically.
If you're bound and determined to use an explicit format string, try 3 or 4 letter M characters. I saw conflicting info about which gave a month abbreviation and which gave a full month name. I think 3 Ms ("MMM") will give a month abbreviation like "Jan 12" and 4 Ms will give the full month name.