ednatmp Posted April 30, 2017 Share Posted April 30, 2017 Hello everyone, I am trying to make a converter from seconds to days, hours and minutes, and gives me error, could you tell me where the problem is? Sorry for my bad English. function secondsToClock(seconds) local seconds = tonumber(seconds) if seconds <= 0 then return "0 día(s), 0 hora(s) y 0 minuto(s)" else local days = math.floor(seconds/86400) local hours = string.format("%02.f", math.floor(seconds/3600 - (days*24))) local mins = string.format("%02.f", math.floor(seconds/60 - (hours*3600) - (days*24))) return days.." día(s), "..hours.." hora(s) y "..mins.." minuto(s)" end end Link to comment
ednatmp Posted April 30, 2017 Author Share Posted April 30, 2017 10 minutes ago, NeXuS™ said: And what is the error? Oh, sorry. On the server, executing a command with that function appears like this: [CHAT] Usted se encuentra silenciado. Expira en 0 día(s), 22 hora(s) y -77823 minuto(s) Link to comment
undefined Posted May 1, 2017 Share Posted May 1, 2017 local mins = string.format("%02.f", math.floor(seconds/60 - (days*24 + hours)*60)) 1 Link to comment
ednatmp Posted May 1, 2017 Author Share Posted May 1, 2017 3 hours ago, ZoRRoM said: local mins = string.format("%02.f", math.floor(seconds/60 - (days*24 + hours)*60)) Now it works perfectly, thank you very much dude! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now