How do I get the epoch time of tomorrow at midnight?
Good question! Here’s some fun math that can help you.
Using os.time() will give you the seconds since epoch, so first calculate the number of seconds in a day.
60 (seconds in a minute) x 60 (minutes in an hour) x 24 (hours in a day) = 86400 seconds per day.
Now, by doing some division and utilizing the math.ceil() function, we can figure out what epoch day would be tomorrow at midnight.
local secondsPerDay = 86400
local timeEpoch = os.time()
local epochDayTomorrow = math.ceil(timeEpoch / secondsPerDay)
-- convert back to seconds
local epochTimeTomorrow = epochDayTomorrow * secondsPerDay
Hope this helps (and that my math is right)
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.