iOS 开发中获取当前系统日期

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

     

   NSDate * senddate=[NSDate date];

        NSCalendar * cal=[NSCalendar currentCalendar];

        NSUInteger unitFlags=NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit;

        NSDateComponents * conponent= [cal components:unitFlags fromDate:senddate];

        NSInteger year=[conponent year];

        NSInteger month=[conponent month];

        NSInteger day=[conponent day];

        NSString * nsDateString= [NSString stringWithFormat:@"%4d/%2d/%2d/",year,month,day];

转载于:https://my.oschina.net/u/1049180/blog/135237

你可能感兴趣的:(iOS 开发中获取当前系统日期)