//⚠️时间转换成模板字符串
+ (NSString *)ConvertStrToTime:(NSString *)timeStr {
long long time=[timeStr longLongValue];
NSDate *d = [[NSDate alloc]initWithTimeIntervalSince1970:time/1000.0];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"yy-MM-dd HH:mm"];
NSString*timeString=[formatter stringFromDate:d];
return timeString;
}
+(NSString*)timeIntervalToStr:(long)timeInterval
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate* confromTimesp = [NSDate dateWithTimeIntervalSince1970:timeInterval];
NSString* timeStr=[formatter stringFromDate:confromTimesp];
return timeStr;
}
//秒数转换成时间格式
- (NSString*)convertTimeToStr:(unsigned int)currentTime
{
int hourF = currentTime / 3600;
int minuteF = (currentTime / 60) % 60;
int secondF = currentTime % 60;
return [NSString stringWithFormat:@"%02d:%02d:%02d",hourF,minuteF,secondF];
}