Jon Sullivan
Jon Sullivan

Reputation: 399

Trouble using showing date on UILabel?

I'm trying to get a label to show the date in the format of (Month) XX, XXXX

Using:

    currentDate = [NSDate date];
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setTimeStyle:NSDateFormatterShortStyle];
    date.text = [dateFormat stringFromDate:currentDate];

Unfortunately, the label text doesn't even change, what am I doing wrong?

Upvotes: 0

Views: 532

Answers (1)

Ravindhiran
Ravindhiran

Reputation: 5384

Try this

  first you have set IBOutlet connection date label

NSDate *currentDate = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM  YYYY"];
date.text = [dateFormat stringFromDate:currentDate]

Upvotes: 1

Related Questions