Os.time() and os.date() issues?

Hello! To test this out, I’m setting the next event to the current time + 100 seconds.

But when it prints out, it says there’s 1 day until the event. Can someone explain this?

local currentTime = os.time() + 100

while wait(1) do
    local diffSeconds = currentTime - os.time()
    local countdown = os.date( '!*t', diffSeconds ) 

    print( ( 'There are %i days, %i hours, %i minutes and %i seconds until event' ):format( countdown.yday, countdown.hour, countdown.min, countdown.sec ) )


countdown.yday will always have a value greater than 0 as “day number 0” of a year can’t exist. You can easily circumvent this by subtracting one.

1 Like

I’ll try that ty!

30 characters

Here is a table explaining the values returned by os.date

1 Like