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

Milliseconds not working?

Asked by 9 years ago

Hi guys! I have a time value in the format of 00:00:00000 I am trying to condense this down to 00:00:000 (Minutes, seconds and then milliseconds etc. up to 3 after the decimal place)

Any ideas why this is not working to do that? :(

function DigitalTime(TimeNum)
local Time = math.max(0, TimeNum)
local minutes = math.floor(Time / 60) % 60
local seconds = math.floor(Time) % 60
local m = tostring(math.floor((TimeNum%60)*100000))
local Timestring = string.format("d:d", minutes, seconds, m)
return Timestring
end



lol = 62.3034
A = DigitalTime(lol)
print(A)

It prints 1:02 Any help would be appreciated :) Thanks!

0
Your over complicating things for the Timestring, string.format(minutes..":"..seconds..":"..m). As for the rounding to the third decimal place, I'm not quite sure. BobserLuck 367 — 9y
0
This website cannot display these format strings. This website is broken. 1waffle1 2908 — 9y

1 answer

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

This website cannot display format strings because of how it interprets percent signs, but you are missing the third argument in the format string from what I can read.

" % 0 2 d : % 0 2 d : % 0 4 d " will work once you take out the spaces.

0
Thank you, but now it displays it as 01:02:230340 which is too many :/ jjwood1600 215 — 9y
0
No problem - fixed it myself! :D jjwood1600 215 — 9y
Ad

Answer this question