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

Set text to show release date not working?

Ello, so I'm trying to make a textLabel set a release date for a game, and it wont work? It displays "Label".

Code: (check below for errors)

local releaseUnix = 1606694399

script.Parent.Frame.TextLabel.Text = "Site-REDACTED Roleplay doesnt release until "..os.date("t*!","%A",releaseUnix).." the "..os.date("t*!","%d",releaseUnix).." of "..os.date("t*!","%B",releaseUnix)..", "..os.date("t*!","%Y",releaseUnix).." at "..os.date("t*!","%I","%p",releaseUnix).." UTC."

Error "Players.Player1.PlayerGui.ScreenGui.LocalScript:4: invalid argument #2 to 'date' (number expected, got string)"

First time working with os.time()/os.date()

Thanks, Blxefirx

1 answer

✓ Accepted 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.

#Documentation

os.date

1 comment

0

OH! I see, thanks

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