//获得系统时间
NSDate * senddate=[NSDate date];
NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@"HH:mm"];
NSString * locationString=[dateformatter stringFromDate:senddate];
[dateformatter setDateFormat:@"YYYY-MM-dd-HH-mm-ss"];
NSString * morelocationString=[dateformatter stringFromDate:senddate];
//获得系统日期
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];
ios获取当前时间和日期
最新推荐文章于 2023-09-02 08:47:01 发布