Вот лучший ответ из Преобразовать целое число секунд в ЧЧ: ММ, iPhone
- (NSString *)timeFormatted:(int)totalSeconds{
int seconds = totalSeconds % 60;
int minutes = (totalSeconds / 60) % 60;
int hours = totalSeconds / 3600;
return [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds];
}
Swift версия:
private func getFormattedVideoTime(totalVideoDuration: Int) -> (hour: Int, minute: Int, seconds: Int){
let seconds = totalVideoDuration % 60
let minutes = (totalVideoDuration / 60) % 60
let hours = totalVideoDuration / 3600
return (hours,minutes,seconds)
}