[ACCEPTED]-NSDateFormatter not showing full month name, only single digit number-nsdateformatter
Turns out to be an issue with the second 6 line, setLocale
. I assume that the system won't 5 default to using english month names when 4 the locale
has been manually set? I live in an 3 english speaking locale
, but maybe it doesn't 2 matter.
In any case, not setting the locale 1 fixes the month name issue.
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setTimeZone:[NSTimeZone localTimeZone]];
[dateFormat setDateFormat:@"MMMM dd, h:mm a"];
The problem is the locale, not the format. Check 2 this out:
http://waracle.net/mobile/iphone-nsdateformatter-date-formatting-table/
Basically, "MMMM" will 1 give you the full name for the month.
-systemLocale
is not what you want here. It returns a 5 fallback locale if no other locale fits. Use 4 -currentLocale
to get the user's current locale.
Also:
You 3 should use NSDateFormatter
's +dateFormatFromTemplate:options:locale:
method to get the correct 2 date format. In some languages the day comes 1 before the month, etc. and vice versa.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.