Delete year for date format in relation to user locale

I want to display the day and month in relation to the locale of the user device.

So, today's date will be displayed as 5/18 with US settings and 18.5. with German decor.
Since I want to handle all possible locales, I can simply simply use [dateFormatter setDateFormat:]and [dateFormatter setDateStyle:NSDateFormatterShortStyle]to display the year.

Also, is there a more elegant way to determine the year value in a row and delete it ?

+3
source share
1 answer

I myself found the answer:

[self.dateFormatter setDateFormat:[NSDateFormatter dateFormatFromTemplate:@"MM d"
                                                                  options:0 
                                                                   locale:[NSLocale currentLocale]]];

For more information, see the Apple documentation at dateFormatFromTemplate

+10
source

All Articles