**iOS时间格式化方法** //时间转换方法 // long nowT = time(NULL); 获取当前时间 - (NSString *)revertTimeFormat:(long)timesp{ NSDate *data = [NSDate dateWithTimeIntervalSince1970:timesp];//获得data NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; //时间格式化属性 [formatter setDateStyle:NSDateFormatterMediumStyle]; [formatter setTimeStyle:NSDateFormatterShortStyle]; [formatter setDateFormat:@"yyyy-MM-dd"]; // [formatter setDateFormat:@"yyyy-MM-dd HH:MM:ss"]; NSString *timeStr = [formatter stringFromDate:data]; //当前时间字符串 return timeStr; }
时间: 2024-10-05 04:58:58