Checking how many weeks have passed since a date using os.time

Doing a thing where it’d check how many weeks have passed since a specific date, tried looking up some stuff on this, couldn’t really find anything about it, so I was wondering how it could be done

You can actually get the number of seconds that have passed since a specific time by using os.time

local specific_time = os.time({year = 2025, month = 1, day = 1})

Then you can calculate the number of weeks that have passed since “specific_time”

local current_time = os.time()
local difference = current_time - specific_time
local weeks_passed = math.floor(difference / 604800) -- 604800 = seconds in a week
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.