iOS: How to get a proper Month name from a number?

Another option is to use the monthSymbols method:

int monthNumber = 11;   //November
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
NSString *monthName = [[df monthSymbols] objectAtIndex:(monthNumber-1)];

Note that you’ll need to subtract 1 from your 1..12 monthNumber since monthSymbols is zero-based.

Leave a Comment