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

An 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.
iOS: How to get a proper Month name from a number? iOS: How to get a proper Month name from a number? Reviewed by Ricardo on 17:44 Rating: 5

No hay comentarios:

Con la tecnología de Blogger.