Convert ms to M:S:MS

How do I convert ms to the minutes:seconds:milliseconds

I’ve tried this but it doesn’t work

function convertTime(courseTime)
	courseTime *= 10	
	
	local m = math.floor(courseTime/60) 
	local s = math.floor(courseTime%60)
	local ms = math.floor((courseTime%1)*1000) 
	print(string.format("%02i:%02i:%02i", m, s, ms))
end

Milliseconds are one-thousandths of a second, meaning 1s equals 1000ms.

local courseTimeSeconds = math.floor(courseTime / 1000) --To get the value in seconds
local m = math.floor(courseTimeSeconds / 60) 
local s = math.floor(courseTimeSeconds % 60)
local ms = math.floor(courseTime % 1000) 
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.