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

Why wouldn't the os.date system work in roblox studio?

Today's Date is 11/4/2020 and it's not working for some reason. Please try to fix my problem.

local date = os.date("*t",os.time())

if date["Month"] == 11 and date["day"] >= 4 then
	print("This is Today's Date.")
else
	print("This is not Today's Date.")
end

In the output error it says This is not Today's Date. It prints the else statement.

2 comments

0

Output error, And where's the error?

0

In the output error it says This is not Today's Date. It prints the else statement.

1 answer

os.date takes a string and inserts time values based on given formatStrings.

So it's first value should look something like this:

Today is %x, which is a %A, and the time is %X.

It will take the formatStrings (%x, %A, %X) present in that string and replace them with a time based upon what the second value is, that being your UNIX time. Our example UNIX time will be 906000490.

So the code should look like this:

os.date("Today is %x, which is a %A, and the time is %X.", 906000490)

Putting that into a print will print:

Today is 09/16/98, which is a Wednesday, and the time is 22:48:10.

So your code will have to look more like this:

if os.date(“%m”, os.time()) == 04 then

#Documentation

os.date

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