Search code examples
objective-cnsdatensdateformatter

Date with Month name Objective-C


I have an NSDate object with value for example: "2011-08-26 14:14:51", I want to display "8 August 2011" how to implement it? Thanks.


Solution

  • NSDate *date = [NSDate date]; //I'm using this just to show the this is how you convert a date
    
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateStyle:NSDateFormatterLongStyle]; // day, Full month and year
    [df setTimeStyle:NSDateFormatterNoStyle];  // nothing
    
    NSString *dateString = [df stringFromDate:date]; [df release];