Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I convert tick() to dd:hh:mm:ss.sss?

I'm working on creating a stopwatch using tick() and have found myself in a position where I'm unable to format it. I've tried a few methods using string.format() but can't seem to get it to run the way I'd like.

Example of what I'm trying to do. 86400.123 ---> 01:00:00:00.123

2 answers

I got it to run the way I wanted so here is the code that worked for me.

local function FormatTime(sec)
	return ('i:i:i:i.i'):format(sec / 86400, sec / 60 ^ 2 % 24, sec / 60 % 60, sec % 60, sec * 1000 % 1000)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.