iOS 获取当前某年某月某日

//获取当前年份, 月份, 号数

unsigned unitFlags = NSYearCalendarUnit |NSMonthCalendarUnit |NSDayCalendarUnit;

NSDateComponents *components = [calendar components:unitFlags fromDate:[NSDate date]];

NSLog(@"%ld, %ld, %ld", (long)components.year, (long)components.month, (long)components.day);

你可能感兴趣的:(iOS 获取当前某年某月某日)