Showing posts with label sun. Show all posts
Showing posts with label sun. Show all posts

Thursday, June 28, 2012

Get Day Name in NSDate

In this example we will find what day(Sun, Mon or Tue etc) is it for a given date.



    NSDate *today=[NSDate date];
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"EEEE"];
    NSString *currentDay = [dateFormatter stringFromDate:today];
    NSLog(@"currentDay=%@", currentDay);
    //currentDay is 1 for Sun, 2 for Mon


    [dateFormatter release];