美文网首页
NSDate 获取几年前的时间

NSDate 获取几年前的时间

作者: 西门丨不吹雪 | 来源:发表于2017-04-20 17:36 被阅读55次
  1. 获取到40年前的日期
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setYear:-40];
self.birthDate = [gregorian dateByAddingComponents:dateComponents toDate:[NSDate date] options:0];

未完待续...

相关文章

网友评论

      本文标题:NSDate 获取几年前的时间

      本文链接:https://www.haomeiwen.com/subject/hwblzttx.html