【发布时间】:2015-12-09 07:01:41
【问题描述】:
在 NSDateFormatter 文档中,
如果日期格式化程序使用相对日期格式,它会在可能的情况下用表示相对日期的短语(例如“今天”或“明天”)替换其输出的日期部分。
我正在使用以下代码:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = [NSDateFormatter dateFormatFromTemplate:@"EEEE dMMMM',' hma"
options:0
locale:[NSLocale currentLocale]];
formatter.doesRelativeDateFormatting = YES;
NSLog(@"Date: %@", [formatter stringFromDate:[NSDate date]]);
它记录Date:。
但是在注释掉 formatter.doesRelativeDateFormatting = YES; 时输出是正确的。
Date: Tuesday, 19 August 1:18 pm
我理解doesRelativeDateFormatting 错了吗?
【问题讨论】:
标签: ios iphone nsdateformatter