ios 获取当前时间 格式是 MM-dd HHmmss object-c
可以使用NSDateFormatter来格式化当前时间。
NSDate *currentDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd HH:mm:ss"];
NSString *formattedDate = [dateFormatter stringFromDate:currentDate];
NSLog(@"%@", formattedDate);
这将打印出当前时间的格式化字符串,格式为"MM-dd HH:mm:ss",例如"01-01 12:00:00"。
原文地址: http://www.cveoy.top/t/topic/iXHF 著作权归作者所有。请勿转载和采集!