首页 > 代码库 > 获取年月日时分秒

获取年月日时分秒

NSDate *now = [NSDate date];NSCalendar *cal = [NSCalendar currentCalendar];unsigned int unitFlags = NSWeekdayCalendarUnit NSHourCalendarUnit NSMinuteCalendarUnit NSSecondCalendarUnit;NSDateComponents *dd = [cal components:unitFlags fromDate:now];NSInteger week = [dd weekday];NSInteger hour = [dd hour];NSInteger minute = [dd minute];NSInteger second = [dd second];