Tariq
Tariq

Reputation: 9979

Weekday symbol in MO TU WE ... format?

I need weekday symbol in MO TU WE TH FR SA SU

I am using setDateFormat:@"EEEEE"]; with shortWeekdaySymbols

But it only return Sun Mon etc. Let me know if it is possible ?

Upvotes: 1

Views: 1194

Answers (2)

Shanti K
Shanti K

Reputation: 2918

As rmaddy has mentioned, you can use six E format. That will give you Mo, Tu, We etc. But if you want them in captitals specifically (MO, TU, WE, etc), you can set the veryShortWeekdaySymbols property of the NSDateFormatter object and use the same format mentioned in the question. You can use any Weekday Symbol you wish. As follows:

NSDate *date = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.veryShortWeekdaySymbols = @[@"SU", @"MO", @"TU", @"WE", @"TH", @"FR", @"SA"];
formatter.dateFormat = @"EEEEE";
NSLog(@"%@", [formatter stringFromDate:date]);

Upvotes: 2

rmaddy
rmaddy

Reputation: 318794

According to the Unicode specification you should be able to use the EEEEEE (six E) format to get a two-letter weekday symbol.

Upvotes: 4

Related Questions