nsdate - Getting the month in DateComponents in iOS -


this question has answer here:

i month datecomponents.

my code looks this:

nsdate *date = [nsdate date]; nsdatecomponents* datecomponents = [[nscalendar currentcalendar] components:nsyearcalendarunit|nsmonthcalendarunit|nsdaycalendarunit fromdate:date]; nsstring *month = [nsstring *stringwithformat:@"%i",datecomponents.month]; 

but month integer, month in format of mm or example: november.

how do it?

int monthnumber = 11;  nsdateformatter *df = [[nsdateformatter alloc] init]; nsstring *monthname = [[df monthsymbols] objectatindex:(monthnumber-1)];//because dateformatter zero-based 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -