Reputation: 52227
I want to display the day and the month in respect to the locale of the users device.
So that the date of today would be displayed as 5/18 with american settings and 18.5. with german setting.
As I want to handle every possible locale, I cant just simply use the [dateFormatter setDateFormat:]
and [dateFormatter setDateStyle:NSDateFormatterShortStyle]
will display the year.
Beside trying to identify the year value in the string and removeing it, is there a more elegant way?
Upvotes: 3
Views: 1655
Reputation: 52227
I found the answer myself:
[self.dateFormatter setDateFormat:[NSDateFormatter dateFormatFromTemplate:@"MM d"
options:0
locale:[NSLocale currentLocale]]];
See more at apple documentation on dateFormatFromTemplate
Upvotes: 10