iOS MacOS 系统时间(时间戳)格式化
#pragma mark -原始数据是20220608155116,加工成2022/06/08 15:51:16 -(NSString *)timeString:(NSString *)toIndexstring{ NSMutableArray *arr = [NSMutableArray array]; for (int i=0; i<toIndexstring.length; i+=2) { NSInteger num = 2; if (i == 0){ num = 4; }else if (i<4){ continue; } NSRange subRange = NSMakeRange(i, num); NSString *newStr = [toIndexstring substringWithRange:subRange]; [arr addObject:newStr]; } NSString *arre0 = [arr objectAtIndex:0]; NSString *arre1 = [arr objectAtIndex:1]; NSString *arre2 = [arr objectAtIndex:2]; NSString *arre3 = [arr objectAtIndex:3]; NSString *arre4 = [arr objectAtIndex:4]; NSString *arre5 = [arr objectAtIndex:5]; NSString *rssiConlba = [NSString stringWithFormat:@"%@/%@/%@ %@:%@:%@",arre0,arre1,arre2,arre3,arre4,arre5]; return rssiConlba; }