Reputation: 6051
I am trying to indicate the months names , but my code just show me the number of months like : 3 , 4 , 12
[dateFormatter setDateFormat:@"MM"];
NSString *currMonth = [dateFormatter stringFromDate:today];
month.text = [NSString stringWithFormat:@"%@",currMonth];
Upvotes: 0
Views: 1150
Reputation: 2261
It's not clear if you want the Months or Weekdays from the question?
The month:
[dateFormatter setDateFormat:@"MMMM"];`
The Weekday:
[dateFormatter setDateFormat:@"EEEE"];
Both:
[dateFormatter setDateFormat:@"'Weekday:'EEEE 'Month:'MMMM "];
I refer to this list when I need to know the formats: http://www.alexcurylo.com/blog/2009/01/29/nsdateformatter-formatting/
Upvotes: 2
Reputation: 8357
Your question is about weekdays. Your code is about months. Confusion.
If you chase the links from the class doc you'll get to the unicode formatting documentation.
Also, the stringWithFormat:@"%@"
in your last line is superfluous.
[dateFormatter setDateFormat:@"eee"];
NSString *weekday = [dateFormatter stringFromDate:today];
weekdayField.text = weekday;
Upvotes: 1
Reputation: 2425
This would lead you in the right direction:
https://stackoverflow.com/a/2466033/127036
Upvotes: 1
Reputation: 965
@Mc.Lover You shoud read the documentation first. Check out Managing Weekday Symbols in that.
Upvotes: 2
Reputation: 4994
Change this format :
[dateFormatter setDateFormat:@"MM"];
to this :
[dateFormatter setDateFormat:@"MMMM"];
Upvotes: 4