Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
iuclds 720 Moderation Voter
4 years ago

https://www.roblox.com/library/271818993/Date-Module

Here's a useful module

Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question