Jump to content

Convert seconds to date


ednatmp

Recommended Posts

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

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...