Jump to content

Convert numbers


drk

Recommended Posts

Hi all.

I need help with time conversion. I'm not good at math and I need convert ms to min:sec.

I have a function to convert the time but seconds appear like 0:4 instead of 0:04. I need convert it, can someone help?

Function here:

function convertTime ( time ) 
    local min = math.floor ( time / 60000 ) 
    local sec = math.floor ( ( time / 1000 ) % 60 ) 
    return min, sec 
end 

Link to comment

I DON'T WANT ANY MILLISECONDS TO SECONDS CONVERTER.

What you don't understand in this ? :/ I need a function to convert ms to minutes, seconds and the problem has been solved already.

Edited by Guest
Link to comment

Dude, I don't wanna convert a time to put in a script, I need a function to convert time from getTimePassed function to min - sec -.-

Why no one understand? Why you think I put the function in the topic? If I want just one time to a script I will not lost my time with a function.

Link to comment
-- will return STRING in the form of "00:00" 
  
function convertTime ( time ) 
  local min = math.floor ( time / 60000 ) 
  local sec = time / 1000 % 60 
  return string.format("%02d:%02d", min, sec) 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...