I am receiving a string from the YouTube JSONC api, but the duration is coming as a full number i.e 2321 instead of 23:21 or 2 instead of 0:02. How would I go about fixing t
You should use DateComponentsFormatter if the duration is intended to be user-facing:
let formatter = DateComponentsFormatter() formatter.allowedUnits = [ .minute, .second ] formatter.zeroFormattingBehavior = [ .pad ] let formattedDuration = formatter.string(from: duration)!