I am creating a resort game where I want to log the amount of time a staff member plays a game per week.
So, that means I want to log the amount of time they play every time they join the game, and add it to their weekly total. But, I don’t know how to reset this weekly total after a week ends, is there a way to do this? I have tried thinking up a way using os.date or time, I just don’t understand how. Anyone have any ideas?
Just so you don’t have to look it up: there are 604,800 seconds in a week. os.time gives you the number of seconds that have passed since January 1st, 1970.
Since everyone is replying with using os.time then I decided to uh yes :
System.Times = {
Day = 86400, -- Day in seconds
Week = 86400 * 7, -- Week in Seconds
Month = 86400 * 30, -- Month in seconds
Year = 86400 * 30 * 12, -- Year in seconds
}
You can record the exact date and time of the activity by passing the result of os.time() into os.date(). It returns a table providing values for month, day, day of week, etc.
-- *t for local time, !*t for UTC
-- second argument can be a unix timestamp, but defaults to the current time if left nil
local date = os.date("!*t")
for i,v in pairs(date) do
print(i..": "..tostring(v))
end