How to turn seconds into days/hours/minutes/seconds

Hello! I am trying to program a live event, and I had it all working fine but the countdown is in seconds (I was using UNIX time.) how would I go about making a countdown with days/hours/minutes/seconds, like Jailbreak did with their live event?

Thanks!

everything there should work, except put the “if currenttime >= stopTime then” and the two lines below it right below where you define CurrentTime so the live event doesnt play for new servers after it happened

Yeah, I don’t want it to play for new servers after the StopTime, but my problem is how would I make the time in seconds, turn into days,hours,minutes etc.

1 Like
local seconds = CurrentTime
local minutes = CurrentTime / 60
local hours = CurrentTime / 3600
local days = CurrentTime / 86400
4 Likes

Here is a thread about that with a solution that could help you:

I think that might help you :slight_smile:

I added that to my code, but it comes out with a really large number, when it should be around 9 days. Did I do it wrong?

photo3

Thanks! Ill read it right now!

You’re basically getting the days, hours, minutes and seconds from the UNIX epoch. This can be used to get the time until a point of time in the future:

local t = startTime - CurrentTime
local seconds = t % 60
local minutes = math.floor(t / 60) % 60
local hours = math.floor(t / 3600) % 24
local days = math.floor(t / 86400)
5 Likes

Sorry, I linked the wrong post, here is the real post:

If you need more assistance about how to add seconds or something else, you can ask me.

Wouldn’t the seconds be the os.time because you wrote

local seconds = currenttime

1 Like