iOS:获取 NSDate 的年

NSDate *currentDate = [NSDate date];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* components = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:currentDate]; // Get necessary date components

[components month] //gives you month
[components day] //gives you day
[components year] // gives you year

 

posted @ 2014-01-15 14:30  有妄想症的猫zz  阅读(3103)  评论(0编辑  收藏  举报