Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What would be the best way to check if date expired?

Alright, so this would be very useful for me to check if the date has gone past the expiry date.

Here is an example;

Year = 2016
Month = 9
Day = 18 
Hour = 18
Minute = 24

 -- (9/18/2016 - 18:24) Above is current date
-- (6/18/2016 - 18:24) Below is expiry date

Year = 2016
Month = 6
Day = 18 
Hour = 18
Minute = 24

--[[

It should print whether the expiry date has expired or not 

--]]


I have tried numerous ways, but it's probably because i'm confused. If anyone can help me with this it would be appreciated!

1 answer

✓ Accepted answer

You'd want to use tick(). It is the Unix counter, which is the number of seconds since January 1st, 1970. It exists on all machines and pretty much all programming/scripting languages. You'd want to get the current time using tick(), and compare it to the expiry date's form in tick().

E.g.

if 12121212127 > 12121212126 then
	print("Expired") --The current tick() time is greater than the expiry date's tick() time
else
	print("Not expired") --The current tick() time is less than the expiry date's tick() time

I don't have the time to write up a full solution, but it should be easy to figure out from here.

More info here: http://wiki.roblox.com/index.php?title=Global_namespace/Functions_specific_to_ROBLOX&redirect=no#tick

5 comments

0

I wait over an hour to get an answer from a website that devotes itself to helping others via roblox lua and i get linked to a roblox wiki page..

1

Yes, but you get an explanation and the correct wiki page. All you need now is a way to convert a date into unix time (assuming you need a date to begin with). Another note: use os.time instead of tick, as it works better across servers (although tick is good for getting the time client-side)

0

Forgot about os.time

0

Really man? I got the best response on the roblox scripting section of the forums in less than 5 minutes.. thanks anyways..

0

Also, I wanted the full solution but instead you said you didn't have time, so if you don't have time then don't post. I appreciate your answer and all, but this is part of something i need done asap, i don't want to be learning something small that functions in my game for hours, I learned scripting from looking at other code.

This discussion is preserved as it was. New answers, comments, and votes are closed.