0

我正在尝试获取一个标签以 (Month) XX, XXXX 的格式显示日期

使用:

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

不幸的是,标签文本甚至没有改变,我做错了什么?

4

1 回答 1

1

试试这个

  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]
于 2013-02-26T04:44:23.070 回答