NSDate中分别分离提取出年月日分时秒的方法
NSDate *now = [NSDate date];
NSCalendar *cal = [NSCalendar currentCalendar];
unsigned int unitFlags = NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *dd = [cal components:unitFlags fromDate:now];
int week = [dd weekday];
int hour = [dd hour];
int minute = [dd minute];
second = [dd second];
That is it!
NSDate *now = [NSDate date];
NSCalendar *cal = [NSCalendar currentCalendar];
unsigned int unitFlags = NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *dd = [cal components:unitFlags fromDate:now];
int week = [dd weekday];
int hour = [dd hour];
int minute = [dd minute];
second = [dd second];
That is it!
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net