@peternlewis’ proposal translates to this macro:
_Time Conversion.kmmacros (2.9 KB)
Thanks to the With Format option, I find – in this case – the KM solution is more elegant than the aforementioned AppleScript solution from jesseweb.com:
on FormatSeconds(totalSeconds)
set theHours to (totalSeconds div hours)
set theRemainderSeconds to (totalSeconds mod hours)
set theMinutes to (theRemainderSeconds div minutes)
set theRemainderSeconds to (theRemainderSeconds mod minutes)
if length of (theHours as text) = 1 then
set theHours to "0" & (theHours as text)
end if
if length of (theMinutes as text) = 1 then
set theMinutes to "0" & (theMinutes as text)
end if
if length of (theRemainderSeconds as text) = 1 then
set theRemainderSeconds to "0" & (theRemainderSeconds as text)
end if
set theTimeString to theHours & ":" & theMinutes & ":" & theRemainderSeconds as text
return theTimeString
end FormatSeconds