1

Possible Duplicate:
How do I get the day of the week in Objective-C?

I searched for many solutions on websites but i was unable to find it. For a particular problem I need to know what is the current day of week.In other words I need to know how to know whether it is sunday, monday, tuesday or so on.

Community
  • 1
  • 1
Vaibhav Gautam
  • 2,074
  • 17
  • 17
  • 1
    Did you try to search for answer? http://stackoverflow.com/questions/4269093/how-do-i-get-the-day-of-the-week-in-objective-c – Nickolay Olshevsky Dec 24 '12 at 11:19
  • http://en.wikipedia.org/wiki/Gregorian_calendar the first day of the Gregorian calendar, Friday, 15 October 1582 (the cycle of weekdays was not affected). – Naresh Dec 24 '12 at 11:22

2 Answers2

0
NSCalendar* cal = [NSCalendar currentCalendar];
NSDateComponents* comp = [cal components:NSWeekdayCalendarUnit fromDate:[NSDate date]];
NSLog(@"weekday - %d", [comp weekday]); // 1 = Sunday, 2 = Monday, etc.
Girish
  • 4,692
  • 4
  • 35
  • 55
0
 Try this:

  NSDate *now = [NSDate date];
  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"EEEE"];
  NSLog(@"%@",[dateFormatter stringFromDate:now]);

See this link too Day Name From NSDate?

Community
  • 1
  • 1
Waseem Fastian
  • 33
  • 1
  • 10