Os.date Expired Code script not working

I’m trying to make a code script that can have codes expire after a certain date. I made a test code that expired in 1999 in 2022, so you’d think it would be expired but it isn’t.

		local CodeScript = require(script[CodeName]) -- The Code ModuleScript

		local date = os.date("*t")
		local expire = CodeScript.ExpireDate -- Expiry Date in Script
				
		if date["day"] >= expire.Day and expire["month"] >= expire.Month and date["year"] >= expire.Year then
			print("expired!")
			return "Expired"
		end

When I run the code, the “Expired!” print does not show up. Is there something I’m doing wrong?

code.ExpireDate = {Year = 1999, Month = 8, Day = 31, Hour = 0, Minute = 0, Second = 0}

this is the Expiry Date in the ModuleScript by the way.

1 Like

Oops, This was wrong. The month was pulling from a non-existant “month” value from expired code.

		if date["day"] >= expire.Day and date["month"] >= expire.Month and date["year"] >= expire.Year then
			print("expired!")
			return "Expired"
		end

For future reference, I would suggest using Unix timestamps for this kinds of stuff, where you would simply do this:

if os.time() > timeOfExpiration then
    print("expired")
end

(timeOfExpiration would be a Unix timestamp)