marciokoko marciokoko - 17 days ago 5x
iOS Question

How do I take a date and extract the day in iOS"

I have a webservice that returns the date in this format:


How do i figure out what day this corresponds to?


An alternate method for getting the weekday can be:

NSString *myDateString = @"2013-04-14";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];

NSDate *date = [dateFormatter dateFromString:myDateString];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSWeekdayCalendarUnit fromDate:date];

NSInteger weekday = [components weekday];
NSString *weekdayName = [dateFormatter weekdaySymbols][weekday - 1];

NSLog(@"%@ is a %@", myDateString, weekdayName);