I want to make a daily quests system that resets everyday and it works however I can’t figure out how to display a timer for it on the client. How would I get the amount of time between now and 00:00 UTC (next day)?
1 Like
Research before asking a question here
2 Likes
-- current time
local currentTime = os.time(os.date("!*t"))
-- 00:00 of the next day
local nextDayTime = os.time({year=os.date("!*t", currentTime).year, month=os.date("!*t", currentTime).month, day=os.date("!*t", currentTime).day + 1, hour=0, min=0, sec=0})
-- difference
local timeDifference = nextDayTime - currentTime
-- convert to hours, minutes, and seconds
local hours = math.floor(timeDifference / 3600)
local minutes = math.floor((timeDifference % 3600) / 60)
local seconds = math.floor(timeDifference % 60)
print(string.format("Time until next reset: %02d:%02d:%02d", hours, minutes, seconds))
5 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.