Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

There is zero days left it says one with unix epoch time?

Asked by
MattVSNNL 620 Moderation Voter
3 years ago

I'm making a live event and added a countdown so players know when it will start, But when I tested it, there were 0 days left but it says 1 day left, Can anyone help me?

Here's my code

local timeToStart = 1621196661

local timeToStop = 1621197661

function liveEvent()
    game.Lighting.TimeOfDay = 0
end

while wait(1) do

    local currentTime = os.time()

    if currentTime >= timeToStop then
        break
    end

    if currentTime >= timeToStart then
        print("Start the event")
        liveEvent()
        break
    else
        print(timeToStart - currentTime.." seconds left until the live event!")

        local day = os.date("*t", timeToStart - currentTime)["day"]

        local hours = os.date("*t", timeToStart - currentTime)["hour"]

        local mins = os.date("*t", timeToStart - currentTime)["min"]

        local seconds = os.date("*t", timeToStart - currentTime)["sec"]

        local stringToFormat = day..":"..hours..":"..mins..":"..seconds

        local result = os.date(stringToFormat, day, hours, mins, seconds)

        workspace:FindFirstChild("LiveEventCountdown"):FindFirstChild("SurfaceGui"):FindFirstChild("TextLabel").Text = result

    end

end

Answer this question