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];

1 comment:

  1. I simply stumbled upon your diary and wished to mention that I actually have very enjoyed reading your diary posts. Any approach i will be subscribing to your feed and that i hope you post once more before long.A fantastic presentation. terribly open and informative.You have superbly bestowed your thought during this diary post.Get social name
    The necessary data you announce in your diary is excellently designed and has several helpful articles that would be used together nice resource of information of varied aspects!I assume you provided the simplest services for everybody.