我正在尝试获取标签,以(月)XX,XXXX格式显示日期
使用:
currentDate = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setTimeStyle:NSDateFormatterShortStyle];
date.text = [dateFormat stringFromDate:currentDate];
不幸的是,标签文本甚至没有改变,我做错了什么?
答案 0 :(得分: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]