Is it possible to convert seconds into days, hours, and minutes?

How can I convert seconds into days, hours, and minutes?
I’m trying to convert, let’s say 98640 seconds into this format. I’m expecting it to be 1 day, 3 hours, and 24 minutes. How is it done?

You would have to use a bit of math like getting the seconds into days with math.floor (rounds to the nearest whole number), a % for the quotient and etc, here is a script which might help

and why divide by 86400 (or 3600/60) thats because thats the amount of seconds a day/hours/minute has

local totalSeconds = 98640

local days = math.floor(totalSeconds / 86400)
local remainingSeconds = totalSeconds % 86400
local hours = math.floor(remainingSeconds / 3600)
remainingSeconds = remainingSeconds % 3600
local minutes = math.floor(remainingSeconds / 60)

print("Days:", days)
print("Hours:", hours)
print("Minutes:", minutes)

1 Like

Thanks for the help, I appreciate it!

1 Like

By any chance, can this use os.time()? I forgot to mention that I’m using this for a ban system.

1 Like

I am not really sure, but I think it should if you just put the variable inside of it

1 Like

u can i do the EXACT same thing

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.