tags:

views:

338

answers:

2

I know that I can figure out today's date by [NSDate date]; but how would I find out today day of the week, like Saturday, Friday etc.

I know that %w can be used in NSDateFormatter, but I don't know to use it.

+2  A: 
NSCalendar* cal = [NSCalendar currentCalendar];
NSDateComponents* comp = [cal components:NSWeekdayCalendarUnit fromDate:[NSDate date]];
return [comp weekday]; // 1 = Sunday, 2 = Monday, etc.
KennyTM
Thanks a lot Kenny. That worked perfectly.
Vibhor Goyal
A: 

I took this further to allow displaying day of the week as a string. Check this link:

http://www.mycsharpcorner.com/Post.aspx?postID=63

Yousef